elasticsearch,lucene,logstash,Java,Eclipse,elasticsearch,Lucene,Logstash" /> elasticsearch,lucene,logstash,Java,Eclipse,elasticsearch,Lucene,Logstash" />

Erro:java.lang.NoSuchFieldError:LUCENE_5_2_1

Erro:java.lang.NoSuchFieldError:LUCENE_5_2_1,java,eclipse,elasticsearch,lucene,logstash,Java,Eclipse,elasticsearch,Lucene,Logstash,我试图使用java API索引到弹性搜索,然后在Kibana中使用该数据进行可视化,如下所示: package elasticSearchTest; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import java.net.InetAddress; import org.elasticsearch.action.index.IndexResponse; import org.elas

我试图使用java API索引到弹性搜索,然后在Kibana中使用该数据进行可视化,如下所示:

package elasticSearchTest;

import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import java.net.InetAddress;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.testng.annotations.Test;

public class ES_Test_Class {
  @Test
  public void f() {
  try{
      Client client = TransportClient.builder().build()
               .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));


      IndexResponse response = client.prepareIndex("twitter", "tweet", "1")
                .setSource(jsonBuilder()
                            .startObject()
                                .field("user", "kimchy")
                                .field("postDate", "18/May/2011:01:48:10")
                                .field("message", "trying out Elasticsearch")
                            .endObject()
                          )
                .get();
    // Document ID (generated or not)
      String _id = response.getId();
    // Version (if it's the first time you index this document, you will get: 1)
    long _version = response.getVersion();

    System.out.println("Document id is: "+_id);

    System.out.println("Document version is: "+_version);
      }
      catch (Exception e){
          e.printStackTrace();
      }

  }
}
以下是更新的依赖项:

但是,当我运行代码时,我发现以下错误:

[TestNG]正在运行: C:\Users\vinbhask\AppData\Local\Temp\testngeclipse--931338640\testng-customsuite.xml 2016年11月4日晚上9:03:52 org.elasticsearch.plugins.PluginsService 信息:[Kismet]模块[],插件[],站点[] 失败:f java.lang.NoSuchFieldError:LUCENE_5_2_1 在org.elasticsearch.Version.(Version.java:265) 位于org.elasticsearch.client.transport.TransportClient$Builder.build(TransportClient.java:129) 在elasticSearchTest.ES_Test_Class.f(ES_Test_Class.java:17) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)中 位于java.lang.reflect.Method.invoke(Method.java:497) 位于org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84) 位于org.testng.internal.Invoker.invokeMethod(Invoker.java:714) 位于org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) 位于org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) 位于org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) 位于org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)

我试着用谷歌搜索解决方案,但遇到了问题,但无法理解如何解决这个问题,我甚至通过一次添加一个JAR来重建项目,但没有任何帮助

[更新]: 添加lucene 5.5.2 jar后出现以下错误:

[TestNG]正在运行: C:\Users\vinbhask\AppData\Local\Temp\testngeclipse--545647994\testng-customsuite.xml 2016年11月6日上午9:18:20 org.elasticsearch.plugins.PluginsService 信息:[轨迹]模块[],插件[],站点[] 失败:f java.lang.NoSuchMethodError:org.jboss.netty.channel.socket.nio.niowerpool(Ljava/util/concurrent/Executor;I)V 位于org.elasticsearch.transport.netty.NettyTransport.createClientBootstrap(NettyTransport.java:354) 位于org.elasticsearch.transport.netty.NettyTransport.doStart(NettyTransport.java:290) 位于org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68) 在org.elasticsearch.transport.TransportService.doStart(TransportService.java:182)上 位于org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68) 位于org.elasticsearch.client.transport.TransportClient$Builder.build(TransportClient.java:162) 在elasticSearchTest.ES_Test_Class.f(ES_Test_Class.java:17) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)中 位于java.lang.reflect.Method.invoke(Method.java:497) 位于org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)


您正在使用Lucene 4.10.4,但Elasticsearch 2.4.1基于Lucene 5.5.2。升级您的Lucene版本()。

我的项目中使用的库也会遇到此问题。