当前位置: 首页 > 知识库问答 >
问题:

弹性6.5不支持IndexRequest

索嘉胜
2023-03-14

问题

我在Java使用RestHighLevelClient构建CRUD。

我无法导入这些包裹

        import org.elasticsearch.action.index.IndexRequest;
        import org.elasticsearch.action.index.IndexResponse;
        import org.elasticsearch.ElasticsearchException;
        import org.elasticsearch.action.delete.DeleteRequest;
        import org.elasticsearch.action.delete.DeleteResponse;
        import org.elasticsearch.action.get.GetRequest;
        import org.elasticsearch.action.get.GetResponse;
        import org.elasticsearch.action.index.IndexRequest;
        import org.elasticsearch.action.index.IndexResponse;
        import org.elasticsearch.action.update.UpdateRequest;
        import org.elasticsearch.action.update.UpdateResponse;

错误

无法解析导入org.elasticsearch.action

Java电码

        private static Person insertPerson(Person person) {
                    person.setPersonId(UUID.randomUUID().toString());
                    Map<String, Object> dataMap = new HashMap<String, Object>();
                    dataMap.put("personId", person.getPersonId());
                    dataMap.put("name", person.getName());
                    IndexRequest indexRequest = new IndexRequest(INDEX, TYPE, person.getPersonId()).source(dataMap);
                   IndexResponse response = restHighLevelClient.index(indexRequest);
                  }

Eclipse表示错误

该行的多个标记-IndexRequest无法解析为类型-IndexRequest无法解析为类型

pom.xml

                <?xml version="1.0" encoding="UTF-8"?>
                <project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                  <modelVersion>4.0.0</modelVersion>
                  <groupId>org.elasticsearch</groupId>
                  <artifactId>elasticsearch</artifactId>
                  <version>6.5.1</version>
                  <dependencies>
                   <dependency>
                      <groupId>org.elasticsearch</groupId>
                      <artifactId>elasticsearch</artifactId>
                      <version>6.5.1</version>
                      <scope>compile</scope>
                    </dependency>
                    <dependency>
                      <groupId>org.elasticsearch</groupId>
                      <artifactId>elasticsearch-core</artifactId>
                      <version>6.5.1</version>
                      <scope>compile</scope>
                    </dependency>
                    <dependency>
                    <groupId>org.elasticsearch.client</groupId>
                    <artifactId>elasticsearch-rest-high-level-client</artifactId>
                    <version>6.5.1</version>
                    </dependency>
                    <dependency>
                      <groupId>com.fasterxml.jackson.core</groupId>
                      <artifactId>jackson-databind</artifactId>
                      <version>2.8.11.3</version>
                      <scope>compile</scope>
                    </dependency>
                    <dependency>
                      <groupId>com.fasterxml.jackson.core</groupId>
                      <artifactId>jackson-core</artifactId>
                      <version>2.8.10</version>
                      <scope>compile</scope>
                    </dependency>
                    <dependency>
                      <groupId>org.elasticsearch</groupId>
                      <artifactId>elasticsearch-secure-sm</artifactId>
                      <version>6.5.1</version>
                      <scope>compile</scope>
                    </dependency>
                   <dependency>
                        <groupId>org.elasticsearch.client</groupId>
                        <artifactId>elasticsearch-rest-client-sniffer</artifactId>
                        <version>6.5.1</version>
                   </dependency>
                    <dependency>
                      <groupId>org.elasticsearch</groupId>
                      <artifactId>elasticsearch-secure-sm</artifactId>
                      <version>6.5.1</version>
                      <scope>compile</scope>
                    </dependency>
                    <dependency>
                      <groupId>org.elasticsearch</groupId>
                      <artifactId>elasticsearch-x-content</artifactId>
                      <version>6.5.1</version>
                      <scope>compile</scope>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.lucene</groupId>
                      <artifactId>lucene-core</artifactId>
                      <version>7.5.0</version>
                      <scope>compile</scope>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.lucene</groupId>
                      <artifactId>lucene-analyzers-common</artifactId>
                      <version>7.5.0</version>
                      <scope>compile</scope>
                      <exclusions>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-core</artifactId>
                        </exclusion>
                      </exclusions>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.lucene</groupId>
                      <artifactId>lucene-backward-codecs</artifactId>
                      <version>7.5.0</version>
                      <scope>compile</scope>
                      <exclusions>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-core</artifactId>
                        </exclusion>
                      </exclusions>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.lucene</groupId>
                      <artifactId>lucene-grouping</artifactId>
                      <version>7.5.0</version>
                      <scope>compile</scope>
                      <exclusions>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-core</artifactId>
                        </exclusion>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-queries</artifactId>
                        </exclusion>
                      </exclusions>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.lucene</groupId>
                      <artifactId>lucene-highlighter</artifactId>
                      <version>7.5.0</version>
                      <scope>compile</scope>
                      <exclusions>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-analyzers-common</artifactId>
                        </exclusion>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-core</artifactId>
                        </exclusion>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-join</artifactId>
                        </exclusion>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-memory</artifactId>
                        </exclusion>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-queries</artifactId>
                        </exclusion>
                      </exclusions>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.lucene</groupId>
                      <artifactId>lucene-join</artifactId>
                      <version>7.5.0</version>
                      <scope>compile</scope>
                      <exclusions>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-core</artifactId>
                        </exclusion>
                      </exclusions>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.lucene</groupId>
                      <artifactId>lucene-memory</artifactId>
                      <version>7.5.0</version>
                      <scope>compile</scope>
                      <exclusions>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-core</artifactId>
                        </exclusion>
                      </exclusions>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.lucene</groupId>
                      <artifactId>lucene-misc</artifactId>
                      <version>7.5.0</version>
                      <scope>compile</scope>
                      <exclusions>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-core</artifactId>
                        </exclusion>
                      </exclusions>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.lucene</groupId>
                      <artifactId>lucene-queries</artifactId>
                      <version>7.5.0</version>
                      <scope>compile</scope>
                      <exclusions>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-core</artifactId>
                        </exclusion>
                      </exclusions>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.lucene</groupId>
                      <artifactId>lucene-queryparser</artifactId>
                      <version>7.5.0</version>
                      <scope>compile</scope>
                      <exclusions>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-core</artifactId>
                        </exclusion>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-queries</artifactId>
                        </exclusion>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-sandbox</artifactId>
                        </exclusion>
                      </exclusions>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.lucene</groupId>
                      <artifactId>lucene-sandbox</artifactId>
                      <version>7.5.0</version>
                      <scope>compile</scope>
                      <exclusions>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-core</artifactId>
                        </exclusion>
                      </exclusions>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.lucene</groupId>
                      <artifactId>lucene-spatial</artifactId>
                      <version>7.5.0</version>
                      <scope>compile</scope>
                      <exclusions>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-core</artifactId>
                        </exclusion>
                      </exclusions>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.lucene</groupId>
                      <artifactId>lucene-spatial-extras</artifactId>
                      <version>7.5.0</version>
                      <scope>compile</scope>
                      <exclusions>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-core</artifactId>
                        </exclusion>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-spatial3d</artifactId>
                        </exclusion>
                        <exclusion>
                          <groupId>io.sgr</groupId>
                          <artifactId>s2-geometry-library-java</artifactId>
                        </exclusion>
                        <exclusion>
                          <groupId>org.locationtech.spatial4j</groupId>
                          <artifactId>spatial4j</artifactId>
                        </exclusion>
                      </exclusions>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.lucene</groupId>
                      <artifactId>lucene-spatial3d</artifactId>
                      <version>7.5.0</version>
                      <scope>compile</scope>
                      <exclusions>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-core</artifactId>
                        </exclusion>
                      </exclusions>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.lucene</groupId>
                      <artifactId>lucene-suggest</artifactId>
                      <version>7.5.0</version>
                      <scope>compile</scope>
                      <exclusions>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-analyzers-common</artifactId>
                        </exclusion>
                        <exclusion>
                          <groupId>org.apache.lucene</groupId>
                          <artifactId>lucene-core</artifactId>
                        </exclusion>
                      </exclusions>
                    </dependency>
                    <dependency>
                      <groupId>org.elasticsearch</groupId>
                      <artifactId>elasticsearch-cli</artifactId>
                      <version>6.5.1</version>
                      <scope>compile</scope>
                    </dependency>
                    <dependency>
                      <groupId>com.carrotsearch</groupId>
                      <artifactId>hppc</artifactId>
                      <version>0.7.1</version>
                      <scope>compile</scope>
                    </dependency>
                    <dependency>
                      <groupId>joda-time</groupId>
                      <artifactId>joda-time</artifactId>
                      <version>2.10.1</version>
                      <scope>compile</scope>
                    </dependency>
                    <dependency>
                      <groupId>com.tdunning</groupId>
                      <artifactId>t-digest</artifactId>
                      <version>3.2</version>
                      <scope>compile</scope>
                    </dependency>
                    <dependency>
                      <groupId>org.hdrhistogram</groupId>
                      <artifactId>HdrHistogram</artifactId>
                      <version>2.1.9</version>
                      <scope>compile</scope>
                    </dependency>
                    <dependency>
                      <groupId>org.locationtech.spatial4j</groupId>
                      <artifactId>spatial4j</artifactId>
                      <version>0.7</version>
                      <scope>compile</scope>
                      <optional>true</optional>
                    </dependency>
                    <dependency>
                      <groupId>org.locationtech.jts</groupId>
                      <artifactId>jts-core</artifactId>
                      <version>1.15.0</version>
                      <scope>compile</scope>
                      <optional>true</optional>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.logging.log4j</groupId>
                      <artifactId>log4j-api</artifactId>
                      <version>2.11.1</version>
                      <scope>compile</scope>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.logging.log4j</groupId>
                      <artifactId>log4j-core</artifactId>
                      <version>2.11.1</version>
                      <scope>compile</scope>
                      <exclusions>
                        <exclusion>
                          <groupId>org.apache.logging.log4j</groupId>
                          <artifactId>log4j-api</artifactId>
                        </exclusion>
                      </exclusions>
                      <optional>true</optional>
                    </dependency>
                    <dependency>
                      <groupId>org.apache.logging.log4j</groupId>
                      <artifactId>log4j-1.2-api</artifactId>
                      <version>2.11.1</version>
                      <scope>compile</scope>
                      <exclusions>
                        <exclusion>
                          <groupId>org.apache.logging.log4j</groupId>
                          <artifactId>log4j-core</artifactId>
                        </exclusion>
                        <exclusion>
                          <groupId>org.apache.logging.log4j</groupId>
                          <artifactId>log4j-api</artifactId>
                        </exclusion>
                      </exclusions>
                      <optional>true</optional>
                    </dependency>
                    <dependency>
                      <groupId>org.elasticsearch</groupId>
                      <artifactId>jna</artifactId>
                      <version>4.5.1</version>
                      <scope>compile</scope>
                    </dependency>
                  </dependencies>
                  <inceptionYear>2009</inceptionYear>
                  <licenses>
                    <license>
                      <name>The Apache Software License, Version 2.0</name>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
                      <distribution>repo</distribution>
                    </license>
                  </licenses>
                  <developers>
                    <developer>
                      <name>Elastic</name>
                      <url>http://www.elastic.co</url>
                    </developer>
                  </developers>
                  <name>server</name>
                  <description>Elasticsearch subproject :server</description>
                  <url>https://github.com/elastic/elasticsearch</url>
                  <scm>
                    <url>git@github.com:elastic/elasticsearch.git</url>
                  </scm>
                </project>

pom.xml的引用

https://search.maven.org/artifact/org.elasticsearch/elasticsearch/6.5.1/jar

但在弹性文件

https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/Java-rest-high-document-index.html

我尝试安装不同的pom.xml

https://search.maven.org/remotecontent?filepath=org/elasticsearch/client/elasticsearch-rest-high-level-client/6.5.1/elasticsearch-rest-high-level-client-6.5.1.pom

它解析了上面的包,但这个包不包含在Maven目录中。

因此,在pom.xml以上安装后,RestHighLevel停止工作。

我试过了所有的办法,但还是不能解决这些问题。

提前道谢。

共有1个答案

慕容修伟
2023-03-14

我已经解决了这个问题

pom.xml中出现问题

工作代码

            <?xml version="1.0" encoding="UTF-8"?>
            <project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
              <modelVersion>4.0.0</modelVersion>
              <groupId>org.elasticsearch.client</groupId>
              <artifactId>elasticsearch-rest-high-level-client</artifactId>
              <version>6.5.1</version>
              <dependencies>
                <dependency>
                  <groupId>org.elasticsearch</groupId>
                  <artifactId>elasticsearch</artifactId>
                  <version>6.5.1</version>
                  <scope>compile</scope>
                </dependency>
                <dependency>
                  <groupId>org.elasticsearch.client</groupId>
                  <artifactId>elasticsearch-rest-client</artifactId>
                  <version>6.5.1</version>
                  <scope>compile</scope>
                </dependency>
                 <dependency>
                  <groupId>org.elasticsearch.client</groupId>
                  <artifactId>transport</artifactId>
                  <version>6.5.1</version>
                  <scope>compile</scope>
                </dependency>
                <dependency>
                    <groupId>org.elasticsearch.client</groupId>
                    <artifactId>elasticsearch-rest-client-sniffer</artifactId>
                    <version>6.5.1</version>
               </dependency>
                <dependency>
                  <groupId>org.elasticsearch.plugin</groupId>
                  <artifactId>parent-join-client</artifactId>
                  <version>6.5.1</version>
                  <scope>compile</scope>
                </dependency>
                <dependency>
                  <groupId>org.elasticsearch.plugin</groupId>
                  <artifactId>aggs-matrix-stats-client</artifactId>
                  <version>6.5.1</version>
                  <scope>compile</scope>
                </dependency>
                <dependency>
                  <groupId>org.elasticsearch.plugin</groupId>
                  <artifactId>rank-eval-client</artifactId>
                  <version>6.5.1</version>
                  <scope>compile</scope>
                </dependency>
                <dependency>
                  <groupId>org.elasticsearch.plugin</groupId>
                  <artifactId>lang-mustache-client</artifactId>
                  <version>6.5.1</version>
                  <scope>compile</scope>
                </dependency>
                <dependency>
                  <groupId>com.fasterxml.jackson.core</groupId>
                  <artifactId>jackson-databind</artifactId>
                  <version>2.8.11.3</version>
                  <scope>compile</scope>
                </dependency>
                <dependency>
                  <groupId>com.fasterxml.jackson.core</groupId>
                  <artifactId>jackson-core</artifactId>
                  <version>2.8.10</version>
                  <scope>compile</scope>
                </dependency>
                <dependency>
                  <groupId>org.apache.logging.log4j</groupId>
                  <artifactId>log4j-core</artifactId>
                  <version>2.11.1</version>
                  <scope>compile</scope>
               </dependency>
               <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-jdk14</artifactId>
                <version>1.7.25</version>
             </dependency>
               <dependency>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-to-slf4j</artifactId>
                    <version>2.8.2</version>
                </dependency>

              </dependencies>

              <inceptionYear>2009</inceptionYear>
              <licenses>
                <license>
                  <name>The Apache Software License, Version 2.0</name>
                  <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
                  <distribution>repo</distribution>
                </license>
              </licenses>
              <developers>
                <developer>
                  <name>Elastic</name>
                  <url>http://www.elastic.co</url>
                </developer>
              </developers>
              <name>rest-high-level</name>
              <description>Elasticsearch subproject :client:rest-high-level</description>
              <url>https://github.com/elastic/elasticsearch</url>
              <scm>
                <url>git@github.com:elastic/elasticsearch.git</url>
              </scm>
            </project>
 类似资料:
  • 动态 component、slot、template 因为需要在构建阶段将所有的模版编译成小程序所需要的模版,因此动态的组件、模版、slot,目前都是不支持的。 v-once 暂不支持。

  • 基本语法 支持 Vue 的基本模版语法,包括 v-for、v-if 等。 <!-- v-if & v-for --> <div v-for="(item, i) in list"> <div v-if="isEven(i)">{{ i }} - {{ item }}</div> </div> <!-- style & class --> <div :class="classObject"><

  • 弹性搜索不推荐使用方面,建议使用聚合(http://www.Elastic.co/guide/en/elasticsearch/reference/1.x/search-aggregations.html)。 Spring数据弹性搜索目前支持这个吗? 如果有,有样品吗?

  • 不支持的函数/语句 替代方案 说明 php://input $GLOBALS['HTTP_RAW_POST_DATA'] 用于HTTP协议下的应用获取POST的原始数据 exit return 使用exit会导致进程退出,如果要返回请直接用return语句 die return 使用die会导致进程退出,如果要返回请直接用return语句 header WorkermanProtocolsHttp

  • 更新:2018年12月(见“阿尼凯特”答案) 使用 Angular CLI 6 时,您需要使用生成器,因为 ng 弹出已弃用,并且很快就会在 8.0 中删除 更新:2018 年 6 月:角度 6 不支持 ng 弹出** 更新:2017年2月:使用ng弹射 更新:2016 年 11 月:角度 cli 现在只使用 web 包。您只需要使用 npm 安装 -g 角度-cli 进行正常安装。“我们在bet

  • DataSource 接口 不支持 timeout 相关操作 Connection 接口 不支持存储过程,函数,游标的操作 不支持执行 native SQL 不支持 savepoint 相关操作 不支持 Schema/Catalog 的操作 不支持自定义类型映射 Statement 和 PreparedStatement 接口 不支持返回多结果集的语句(即存储过程,非 SELECT 多条数据) 不