2016-11-04 12 views
2

アムのJava APIを使用して弾性検索にインデックスにしようと、後に以下のようKibanaにおける可視化のためにそのデータを使用します。以下はエロ:java.lang.NoSuchFieldErrorの:LUCENE_5_2_1

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(); 
     } 

    } 
} 

は更新の依存関係です:

私は、コードを実行すると

enter image description here

は、しかし、私はエラーの下に取得する:

[TestNG] Running: C:\Users\vinbhask\AppData\Local\Temp\testng-eclipse--931338640\testng-customsuite.xml Nov 04, 2016 9:03:52 PM org.elasticsearch.plugins.PluginsService INFO: [Kismet] modules [], plugins [], sites [] FAILED: f java.lang.NoSuchFieldError: LUCENE_5_2_1 at org.elasticsearch.Version.(Version.java:265) at org.elasticsearch.client.transport.TransportClient$Builder.build(TransportClient.java:129) at elasticSearchTest.ES_Test_Class.f(ES_Test_Class.java:17) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84) at org.testng.internal.Invoker.invokeMethod(Invoker.java:714) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)

私は[更新]解決のためにグーグルで試してみましたthis linkthis linkに出くわしたが、問題を解決する方法を理解することができませんでした、私も一度に一つのJARを追加することではなく、助け無し

のプロジェクトを再構築した:後 をエラーの下になってluceneの5.5.2 jarファイルを追加:

[TestNG] Running: C:\Users\vinbhask\AppData\Local\Temp\testng-eclipse--545647994\testng-customsuite.xml Nov 06, 2016 9:18:20 AM org.elasticsearch.plugins.PluginsService INFO: [Locus] modules [], plugins [], sites [] FAILED: f java.lang.NoSuchMethodError: org.jboss.netty.channel.socket.nio.NioWorkerPool.(Ljava/util/concurrent/Executor;I)V at org.elasticsearch.transport.netty.NettyTransport.createClientBootstrap(NettyTransport.java:354) at org.elasticsearch.transport.netty.NettyTransport.doStart(NettyTransport.java:290) at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68) at org.elasticsearch.transport.TransportService.doStart(TransportService.java:182) at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68) at org.elasticsearch.client.transport.TransportClient$Builder.build(TransportClient.java:162) at elasticSearchTest.ES_Test_Class.f(ES_Test_Class.java:17) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)

+0

また、この問題は、私のプロジェクトで使用されているライブラリにも影響します。 – MarkII

答えて

2

あなたはLuceneの4.10.4を使用しているが、Elasticsearch 2.4.1はLuceneを5.5.2に基づいています。 Luceneバージョン(5.5.2 is here)をアップグレードしてください。

関連する問題