BasicExample ElasticSearch Java using TransportClient and Node

Hi can any body give me the code or steps to communicate elasticsearch
using java.I ahve already created one example,but i am not able to
understand what it is doing, is there any source code or step by step
creation of example in eclipse Using Transoprt Client as well as Node .

here is the code which i found in google and try to execute.

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.elasticsearch.client.Client;
import org.elasticsearch.node.Node;

import static org.elasticsearch.node.NodeBuilder.*;

public class PostES {

public static void main (String args[]){
    PostES p = new PostES();
    p.postElasticSearch();
}


public static Map<String, Object> putJsonDocument(String title, String 

content, Date postDate, String author){

        Map<String, Object> jsonDocument = new HashMap<String, 

Object>();

        jsonDocument.put("title", title);
        jsonDocument.put("conten", content);
        jsonDocument.put("postDate", postDate);
        jsonDocument.put("author", author);

        return jsonDocument;
}


private void postElasticSearch(){

        Node node    = nodeBuilder().node();
        Client client   = node.client();

        client.prepareIndex("testindex", "article")
                  .setSource(putJsonDocument("Example Title",
                                             "This description is so 

important. You dont even know!",
new Date(),
"J.R."))
.execute().actionGet();

        node.close();
    }

}

and i am getting errors as

Exception in thread "main"
org.elasticsearch.common.inject.internal.ComputationException:
org.elasticsearch.common.inject.internal.ComputationException:
java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:553)
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at
org.elasticsearch.common.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at
org.elasticsearch.common.inject.internal.FailableCache.get(FailableCache.java:46)
at
org.elasticsearch.common.inject.ConstructorInjectorStore.get(ConstructorInjectorStore.java:52)
at
org.elasticsearch.common.inject.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:57)
at
org.elasticsearch.common.inject.InjectorImpl.initializeBinding(InjectorImpl.java:377)
at
org.elasticsearch.common.inject.BindingProcessor$1$1.run(BindingProcessor.java:169)
at
org.elasticsearch.common.inject.BindingProcessor.initializeBindings(BindingProcessor.java:224)
at
org.elasticsearch.common.inject.InjectorBuilder.initializeStatically(InjectorBuilder.java:120)
at
org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:105)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:92)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:69)
at
org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:58)
at
org.elasticsearch.node.internal.InternalNode.(InternalNode.java:146)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)
at PostES.postElasticSearch(PostES.java:33)
at PostES.main(PostES.java:14)
Caused by: org.elasticsearch.common.inject.internal.ComputationException:
java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:553)
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at
org.elasticsearch.common.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at
org.elasticsearch.common.inject.internal.FailableCache.get(FailableCache.java:46)
at
org.elasticsearch.common.inject.MembersInjectorStore.get(MembersInjectorStore.java:66)
at
org.elasticsearch.common.inject.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:69)
at
org.elasticsearch.common.inject.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:31)
at
org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:39)
at
org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:35)
at
org.elasticsearch.common.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:549)
... 18 more
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.lang.Class.getDeclaredFields(Unknown Source)
at
org.elasticsearch.common.inject.spi.InjectionPoint$Factory$1.getMembers(InjectionPoint.java:386)
at
org.elasticsearch.common.inject.spi.InjectionPoint$Factory$1.getMembers(InjectionPoint.java:384)
at
org.elasticsearch.common.inject.spi.InjectionPoint.addInjectorsForMembers(InjectionPoint.java:359)
at
org.elasticsearch.common.inject.spi.InjectionPoint.addInjectionPoints(InjectionPoint.java:353)
at
org.elasticsearch.common.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:295)
at
org.elasticsearch.common.inject.MembersInjectorStore.createWithListeners(MembersInjectorStore.java:78)
at
org.elasticsearch.common.inject.MembersInjectorStore.access$000(MembersInjectorStore.java:35)
at
org.elasticsearch.common.inject.MembersInjectorStore$1.create(MembersInjectorStore.java:43)
at
org.elasticsearch.common.inject.MembersInjectorStore$1.create(MembersInjectorStore.java:40)
at
org.elasticsearch.common.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:549)
... 28 more
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.store.Lock
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 42 more

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/f1442407-9697-4af5-96c5-8000cf3778b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I think your class path is incorrect and does not have all needed libs (Lucene here)

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

Le 19 mars 2014 à 10:18:41, Venu Krishna (yvgk2010@gmail.com) a écrit:

Hi can any body give me the code or steps to communicate elasticsearch using java.I ahve already created one example,but i am not able to understand what it is doing, is there any source code or step by step creation of example in eclipse Using Transoprt Client as well as Node .

here is the code which i found in google and try to execute.

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.elasticsearch.client.Client;
import org.elasticsearch.node.Node;

import static org.elasticsearch.node.NodeBuilder.*;

public class PostES {

public static void main (String args[]){
    PostES p = new PostES();
    p.postElasticSearch();
}


public static Map<String, Object> putJsonDocument(String title, String content, Date postDate, String author){

        Map<String, Object> jsonDocument = new HashMap<String, Object>();

        jsonDocument.put("title", title);
        jsonDocument.put("conten", content);
        jsonDocument.put("postDate", postDate);
        jsonDocument.put("author", author);

        return jsonDocument;
}


private void postElasticSearch(){

        Node node    = nodeBuilder().node();
        Client client   = node.client();

        client.prepareIndex("testindex", "article")
                  .setSource(putJsonDocument("Example Title",
                                             "This description is so important. You dont even know!",
                                             new Date(),
                                             "J.R."))
                                             .execute().actionGet();

        node.close();
    }

}

and i am getting errors as

Exception in thread "main" org.elasticsearch.common.inject.internal.ComputationException: org.elasticsearch.common.inject.internal.ComputationException: java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:553)
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at org.elasticsearch.common.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at org.elasticsearch.common.inject.internal.FailableCache.get(FailableCache.java:46)
at org.elasticsearch.common.inject.ConstructorInjectorStore.get(ConstructorInjectorStore.java:52)
at org.elasticsearch.common.inject.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:57)
at org.elasticsearch.common.inject.InjectorImpl.initializeBinding(InjectorImpl.java:377)
at org.elasticsearch.common.inject.BindingProcessor$1$1.run(BindingProcessor.java:169)
at org.elasticsearch.common.inject.BindingProcessor.initializeBindings(BindingProcessor.java:224)
at org.elasticsearch.common.inject.InjectorBuilder.initializeStatically(InjectorBuilder.java:120)
at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:105)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:92)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:69)
at org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:58)
at org.elasticsearch.node.internal.InternalNode.(InternalNode.java:146)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)
at PostES.postElasticSearch(PostES.java:33)
at PostES.main(PostES.java:14)
Caused by: org.elasticsearch.common.inject.internal.ComputationException: java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:553)
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at org.elasticsearch.common.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at org.elasticsearch.common.inject.internal.FailableCache.get(FailableCache.java:46)
at org.elasticsearch.common.inject.MembersInjectorStore.get(MembersInjectorStore.java:66)
at org.elasticsearch.common.inject.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:69)
at org.elasticsearch.common.inject.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:31)
at org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:39)
at org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:35)
at org.elasticsearch.common.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:549)
... 18 more
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.lang.Class.getDeclaredFields(Unknown Source)
at org.elasticsearch.common.inject.spi.InjectionPoint$Factory$1.getMembers(InjectionPoint.java:386)
at org.elasticsearch.common.inject.spi.InjectionPoint$Factory$1.getMembers(InjectionPoint.java:384)
at org.elasticsearch.common.inject.spi.InjectionPoint.addInjectorsForMembers(InjectionPoint.java:359)
at org.elasticsearch.common.inject.spi.InjectionPoint.addInjectionPoints(InjectionPoint.java:353)
at org.elasticsearch.common.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:295)
at org.elasticsearch.common.inject.MembersInjectorStore.createWithListeners(MembersInjectorStore.java:78)
at org.elasticsearch.common.inject.MembersInjectorStore.access$000(MembersInjectorStore.java:35)
at org.elasticsearch.common.inject.MembersInjectorStore$1.create(MembersInjectorStore.java:43)
at org.elasticsearch.common.inject.MembersInjectorStore$1.create(MembersInjectorStore.java:40)
at org.elasticsearch.common.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:549)
... 28 more
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.store.Lock
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 42 more

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/f1442407-9697-4af5-96c5-8000cf3778b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.5329665c.10233c99.97ca%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.

Hi David,which classpath i need to set,can you give me in more specific way.

Thankyou again. :slight_smile:

On Wednesday, March 19, 2014 2:48:37 PM UTC+5:30, Venu Krishna wrote:

Hi can any body give me the code or steps to communicate elasticsearch
using java.I ahve already created one example,but i am not able to
understand what it is doing, is there any source code or step by step
creation of example in eclipse Using Transoprt Client as well as Node .

here is the code which i found in google and try to execute.

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.elasticsearch.client.Client;
import org.elasticsearch.node.Node;

import static org.elasticsearch.node.NodeBuilder.*;

public class PostES {

public static void main (String args[]){
    PostES p = new PostES();
    p.postElasticSearch();
}


public static Map<String, Object> putJsonDocument(String title, String 

content, Date postDate, String author){

        Map<String, Object> jsonDocument = new HashMap<String, 

Object>();

        jsonDocument.put("title", title);
        jsonDocument.put("conten", content);
        jsonDocument.put("postDate", postDate);
        jsonDocument.put("author", author);

        return jsonDocument;
}


private void postElasticSearch(){

        Node node    = nodeBuilder().node();
        Client client   = node.client();

        client.prepareIndex("testindex", "article")
                  .setSource(putJsonDocument("Example Title",
                                             "This description is so 

important. You dont even know!",
new Date(),
"J.R."))
.execute().actionGet();

        node.close();
    }

}

and i am getting errors as

Exception in thread "main"
org.elasticsearch.common.inject.internal.ComputationException:
org.elasticsearch.common.inject.internal.ComputationException:
java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:553)
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at
org.elasticsearch.common.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at
org.elasticsearch.common.inject.internal.FailableCache.get(FailableCache.java:46)
at
org.elasticsearch.common.inject.ConstructorInjectorStore.get(ConstructorInjectorStore.java:52)
at
org.elasticsearch.common.inject.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:57)
at
org.elasticsearch.common.inject.InjectorImpl.initializeBinding(InjectorImpl.java:377)
at
org.elasticsearch.common.inject.BindingProcessor$1$1.run(BindingProcessor.java:169)
at
org.elasticsearch.common.inject.BindingProcessor.initializeBindings(BindingProcessor.java:224)
at
org.elasticsearch.common.inject.InjectorBuilder.initializeStatically(InjectorBuilder.java:120)
at
org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:105)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:92)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:69)
at
org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:58)
at
org.elasticsearch.node.internal.InternalNode.(InternalNode.java:146)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)
at PostES.postElasticSearch(PostES.java:33)
at PostES.main(PostES.java:14)
Caused by: org.elasticsearch.common.inject.internal.ComputationException:
java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:553)
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at
org.elasticsearch.common.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at
org.elasticsearch.common.inject.internal.FailableCache.get(FailableCache.java:46)
at
org.elasticsearch.common.inject.MembersInjectorStore.get(MembersInjectorStore.java:66)
at
org.elasticsearch.common.inject.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:69)
at
org.elasticsearch.common.inject.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:31)
at
org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:39)
at
org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:35)
at
org.elasticsearch.common.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:549)
... 18 more
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.lang.Class.getDeclaredFields(Unknown Source)
at
org.elasticsearch.common.inject.spi.InjectionPoint$Factory$1.getMembers(InjectionPoint.java:386)
at
org.elasticsearch.common.inject.spi.InjectionPoint$Factory$1.getMembers(InjectionPoint.java:384)
at
org.elasticsearch.common.inject.spi.InjectionPoint.addInjectorsForMembers(InjectionPoint.java:359)
at
org.elasticsearch.common.inject.spi.InjectionPoint.addInjectionPoints(InjectionPoint.java:353)
at
org.elasticsearch.common.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:295)
at
org.elasticsearch.common.inject.MembersInjectorStore.createWithListeners(MembersInjectorStore.java:78)
at
org.elasticsearch.common.inject.MembersInjectorStore.access$000(MembersInjectorStore.java:35)
at
org.elasticsearch.common.inject.MembersInjectorStore$1.create(MembersInjectorStore.java:43)
at
org.elasticsearch.common.inject.MembersInjectorStore$1.create(MembersInjectorStore.java:40)
at
org.elasticsearch.common.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:549)
... 28 more
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.store.Lock
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 42 more

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/2ff730a9-6c68-4d4a-b30e-14d1a7915ac2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Well. It depends on how you created your project.
Are you using Maven?
Are you running your program from a command line, from an IDE?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

Le 19 mars 2014 à 11:10:52, Venu Krishna (yvgk2010@gmail.com) a écrit:

Hi David,which classpath i need to set,can you give me in more specific way.

Thankyou again. :slight_smile:

On Wednesday, March 19, 2014 2:48:37 PM UTC+5:30, Venu Krishna wrote:
Hi can any body give me the code or steps to communicate elasticsearch using java.I ahve already created one example,but i am not able to understand what it is doing, is there any source code or step by step creation of example in eclipse Using Transoprt Client as well as Node .

here is the code which i found in google and try to execute.

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.elasticsearch.client.Client;
import org.elasticsearch.node.Node;

import static org.elasticsearch.node.NodeBuilder.*;

public class PostES {

public static void main (String args[]){
    PostES p = new PostES();
    p.postElasticSearch();
}


public static Map<String, Object> putJsonDocument(String title, String content, Date postDate, String author){

        Map<String, Object> jsonDocument = new HashMap<String, Object>();

        jsonDocument.put("title", title);
        jsonDocument.put("conten", content);
        jsonDocument.put("postDate", postDate);
        jsonDocument.put("author", author);

        return jsonDocument;
}


private void postElasticSearch(){

        Node node    = nodeBuilder().node();
        Client client   = node.client();

        client.prepareIndex("testindex", "article")
                  .setSource(putJsonDocument("Example Title",
                                             "This description is so important. You dont even know!",
                                             new Date(),
                                             "J.R."))
                                             .execute().actionGet();

        node.close();
    }

}

and i am getting errors as

Exception in thread "main" org.elasticsearch.common.inject.internal.ComputationException: org.elasticsearch.common.inject.internal.ComputationException: java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:553)
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at org.elasticsearch.common.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at org.elasticsearch.common.inject.internal.FailableCache.get(FailableCache.java:46)
at org.elasticsearch.common.inject.ConstructorInjectorStore.get(ConstructorInjectorStore.java:52)
at org.elasticsearch.common.inject.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:57)
at org.elasticsearch.common.inject.InjectorImpl.initializeBinding(InjectorImpl.java:377)
at org.elasticsearch.common.inject.BindingProcessor$1$1.run(BindingProcessor.java:169)
at org.elasticsearch.common.inject.BindingProcessor.initializeBindings(BindingProcessor.java:224)
at org.elasticsearch.common.inject.InjectorBuilder.initializeStatically(InjectorBuilder.java:120)
at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:105)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:92)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:69)
at org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:58)
at org.elasticsearch.node.internal.InternalNode.(InternalNode.java:146)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)
at PostES.postElasticSearch(PostES.java:33)
at PostES.main(PostES.java:14)
Caused by: org.elasticsearch.common.inject.internal.ComputationException: java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:553)
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at org.elasticsearch.common.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at org.elasticsearch.common.inject.internal.FailableCache.get(FailableCache.java:46)
at org.elasticsearch.common.inject.MembersInjectorStore.get(MembersInjectorStore.java:66)
at org.elasticsearch.common.inject.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:69)
at org.elasticsearch.common.inject.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:31)
at org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:39)
at org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:35)
at org.elasticsearch.common.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:549)
... 18 more
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.lang.Class.getDeclaredFields(Unknown Source)
at org.elasticsearch.common.inject.spi.InjectionPoint$Factory$1.getMembers(InjectionPoint.java:386)
at org.elasticsearch.common.inject.spi.InjectionPoint$Factory$1.getMembers(InjectionPoint.java:384)
at org.elasticsearch.common.inject.spi.InjectionPoint.addInjectorsForMembers(InjectionPoint.java:359)
at org.elasticsearch.common.inject.spi.InjectionPoint.addInjectionPoints(InjectionPoint.java:353)
at org.elasticsearch.common.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:295)
at org.elasticsearch.common.inject.MembersInjectorStore.createWithListeners(MembersInjectorStore.java:78)
at org.elasticsearch.common.inject.MembersInjectorStore.access$000(MembersInjectorStore.java:35)
at org.elasticsearch.common.inject.MembersInjectorStore$1.create(MembersInjectorStore.java:43)
at org.elasticsearch.common.inject.MembersInjectorStore$1.create(MembersInjectorStore.java:40)
at org.elasticsearch.common.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:549)
... 28 more
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.store.Lock
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 42 more

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/2ff730a9-6c68-4d4a-b30e-14d1a7915ac2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.53296dfe.77ae35eb.97ca%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.

Yes,i am using Eclipse Kepler.I have create DynamicWebProject and yes i
have create one pom.xml and respective dependencies of elasticsearch,and i
am running program with the main method,i.e. JavaApplication.

On Wednesday, March 19, 2014 3:44:22 PM UTC+5:30, David Pilato wrote:

Well. It depends on how you created your project.
Are you using Maven?
Are you running your program from a command line, from an IDE?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr

Le 19 mars 2014 à 11:10:52, Venu Krishna (yvgk...@gmail.com <javascript:>)
a écrit:

Hi David,which classpath i need to set,can you give me in more specific
way.

Thankyou again. :slight_smile:

On Wednesday, March 19, 2014 2:48:37 PM UTC+5:30, Venu Krishna wrote:

Hi can any body give me the code or steps to communicate elasticsearch
using java.I ahve already created one example,but i am not able to
understand what it is doing, is there any source code or step by step
creation of example in eclipse Using Transoprt Client as well as Node .

here is the code which i found in google and try to execute.

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.elasticsearch.client.Client;
import org.elasticsearch.node.Node;

import static org.elasticsearch.node.NodeBuilder.*;

public class PostES {

public static void main (String args[]){
    PostES p = new PostES();
    p.postElasticSearch();
}


public static Map<String, Object> putJsonDocument(String title, 

String content, Date postDate, String author){

        Map<String, Object> jsonDocument = new HashMap<String, 

Object>();

        jsonDocument.put("title", title);
        jsonDocument.put("conten", content);
        jsonDocument.put("postDate", postDate);
        jsonDocument.put("author", author);

        return jsonDocument;
}


private void postElasticSearch(){

        Node node    = nodeBuilder().node();
        Client client   = node.client();

        client.prepareIndex("testindex", "article")
                  .setSource(putJsonDocument("Example Title",
                                             "This description is so 

important. You dont even know!",
new Date(),
"J.R."))
.execute().actionGet();

        node.close();
    }

}

and i am getting errors as

Exception in thread "main"
org.elasticsearch.common.inject.internal.ComputationException:
org.elasticsearch.common.inject.internal.ComputationException:
java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:553)
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at
org.elasticsearch.common.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at
org.elasticsearch.common.inject.internal.FailableCache.get(FailableCache.java:46)
at
org.elasticsearch.common.inject.ConstructorInjectorStore.get(ConstructorInjectorStore.java:52)
at
org.elasticsearch.common.inject.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:57)
at
org.elasticsearch.common.inject.InjectorImpl.initializeBinding(InjectorImpl.java:377)
at
org.elasticsearch.common.inject.BindingProcessor$1$1.run(BindingProcessor.java:169)
at
org.elasticsearch.common.inject.BindingProcessor.initializeBindings(BindingProcessor.java:224)
at
org.elasticsearch.common.inject.InjectorBuilder.initializeStatically(InjectorBuilder.java:120)
at
org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:105)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:92)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:69)
at
org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:58)
at
org.elasticsearch.node.internal.InternalNode.(InternalNode.java:146)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)
at PostES.postElasticSearch(PostES.java:33)
at PostES.main(PostES.java:14)
Caused by: org.elasticsearch.common.inject.internal.ComputationException:
java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:553)
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at
org.elasticsearch.common.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at
org.elasticsearch.common.inject.internal.FailableCache.get(FailableCache.java:46)
at
org.elasticsearch.common.inject.MembersInjectorStore.get(MembersInjectorStore.java:66)
at
org.elasticsearch.common.inject.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:69)
at
org.elasticsearch.common.inject.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:31)
at
org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:39)
at
org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:35)
at
org.elasticsearch.common.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:549)
... 18 more
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.lang.Class.getDeclaredFields(Unknown Source)
at
org.elasticsearch.common.inject.spi.InjectionPoint$Factory$1.getMembers(InjectionPoint.java:386)
at
org.elasticsearch.common.inject.spi.InjectionPoint$Factory$1.getMembers(InjectionPoint.java:384)
at
org.elasticsearch.common.inject.spi.InjectionPoint.addInjectorsForMembers(InjectionPoint.java:359)
at
org.elasticsearch.common.inject.spi.InjectionPoint.addInjectionPoints(InjectionPoint.java:353)
at
org.elasticsearch.common.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:295)
at
org.elasticsearch.common.inject.MembersInjectorStore.createWithListeners(MembersInjectorStore.java:78)
at
org.elasticsearch.common.inject.MembersInjectorStore.access$000(MembersInjectorStore.java:35)
at
org.elasticsearch.common.inject.MembersInjectorStore$1.create(MembersInjectorStore.java:43)
at
org.elasticsearch.common.inject.MembersInjectorStore$1.create(MembersInjectorStore.java:40)
at
org.elasticsearch.common.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:549)
... 28 more
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.store.Lock
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 42 more

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/2ff730a9-6c68-4d4a-b30e-14d1a7915ac2%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/2ff730a9-6c68-4d4a-b30e-14d1a7915ac2%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/cfb33159-123e-4ba5-9adb-071ca77a3a52%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi David,i will make it simple.My main moto is using java i want to do CRUD
operations with Elasticsearch,in this process i came to know about
Elasticsearch related Java
Api's URL :

,from this i followed the steps as it is starting from Maven to Client
Api.I am using Eclipse Kepler and created WebDynamic Project and build the
respective jars,and copied the code from Client Api(Node based and
TransportClient) and execute using JavaApplication i.e.main() which uses
console app i.e. eclipse cmd. so,for now am trying atleast to connect to
Elasticsearch ,after getting this then i will move on with CRUD operations
using JSON. ANY GUIDANCE GIVEN WILL BE HIGHLY APPRECIATED.

URGENT REQUIREMENT.
Thanks in advance.
On Wednesday, March 19, 2014 2:48:37 PM UTC+5:30, Venu Krishna wrote:

Hi can any body give me the code or steps to communicate elasticsearch
using java.I ahve already created one example,but i am not able to
understand what it is doing, is there any source code or step by step
creation of example in eclipse Using Transoprt Client as well as Node .

here is the code which i found in google and try to execute.

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.elasticsearch.client.Client;
import org.elasticsearch.node.Node;

import static org.elasticsearch.node.NodeBuilder.*;

public class PostES {

public static void main (String args[]){
    PostES p = new PostES();
    p.postElasticSearch();
}


public static Map<String, Object> putJsonDocument(String title, String 

content, Date postDate, String author){

        Map<String, Object> jsonDocument = new HashMap<String, 

Object>();

        jsonDocument.put("title", title);
        jsonDocument.put("conten", content);
        jsonDocument.put("postDate", postDate);
        jsonDocument.put("author", author);

        return jsonDocument;
}


private void postElasticSearch(){

        Node node    = nodeBuilder().node();
        Client client   = node.client();

        client.prepareIndex("testindex", "article")
                  .setSource(putJsonDocument("Example Title",
                                             "This description is so 

important. You dont even know!",
new Date(),
"J.R."))
.execute().actionGet();

        node.close();
    }

}

and i am getting errors as

Exception in thread "main"
org.elasticsearch.common.inject.internal.ComputationException:
org.elasticsearch.common.inject.internal.ComputationException:
java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:553)
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at
org.elasticsearch.common.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at
org.elasticsearch.common.inject.internal.FailableCache.get(FailableCache.java:46)
at
org.elasticsearch.common.inject.ConstructorInjectorStore.get(ConstructorInjectorStore.java:52)
at
org.elasticsearch.common.inject.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:57)
at
org.elasticsearch.common.inject.InjectorImpl.initializeBinding(InjectorImpl.java:377)
at
org.elasticsearch.common.inject.BindingProcessor$1$1.run(BindingProcessor.java:169)
at
org.elasticsearch.common.inject.BindingProcessor.initializeBindings(BindingProcessor.java:224)
at
org.elasticsearch.common.inject.InjectorBuilder.initializeStatically(InjectorBuilder.java:120)
at
org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:105)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:92)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:69)
at
org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:58)
at
org.elasticsearch.node.internal.InternalNode.(InternalNode.java:146)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)
at PostES.postElasticSearch(PostES.java:33)
at PostES.main(PostES.java:14)
Caused by: org.elasticsearch.common.inject.internal.ComputationException:
java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:553)
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at
org.elasticsearch.common.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at
org.elasticsearch.common.inject.internal.FailableCache.get(FailableCache.java:46)
at
org.elasticsearch.common.inject.MembersInjectorStore.get(MembersInjectorStore.java:66)
at
org.elasticsearch.common.inject.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:69)
at
org.elasticsearch.common.inject.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:31)
at
org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:39)
at
org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:35)
at
org.elasticsearch.common.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:549)
... 18 more
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.lang.Class.getDeclaredFields(Unknown Source)
at
org.elasticsearch.common.inject.spi.InjectionPoint$Factory$1.getMembers(InjectionPoint.java:386)
at
org.elasticsearch.common.inject.spi.InjectionPoint$Factory$1.getMembers(InjectionPoint.java:384)
at
org.elasticsearch.common.inject.spi.InjectionPoint.addInjectorsForMembers(InjectionPoint.java:359)
at
org.elasticsearch.common.inject.spi.InjectionPoint.addInjectionPoints(InjectionPoint.java:353)
at
org.elasticsearch.common.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:295)
at
org.elasticsearch.common.inject.MembersInjectorStore.createWithListeners(MembersInjectorStore.java:78)
at
org.elasticsearch.common.inject.MembersInjectorStore.access$000(MembersInjectorStore.java:35)
at
org.elasticsearch.common.inject.MembersInjectorStore$1.create(MembersInjectorStore.java:43)
at
org.elasticsearch.common.inject.MembersInjectorStore$1.create(MembersInjectorStore.java:40)
at
org.elasticsearch.common.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at
org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:549)
... 28 more
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.store.Lock
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 42 more

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/ee2e8cf8-7b69-4493-8e87-c7517be8c4ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

You don't have to repeat yourself and open many threads for the same thing.

Let me focus on elasticsearch. I'm not going to answer about your IDE and how you should setup java applications.

If you are using Maven (recommended), you just need to follow what we wrote here: http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/_maven_repository.html

Add a dependency like:

org.elasticsearch
elasticsearch
1.0.1

If you are not using Maven, you need to add elasticsearch-1.0.1.jar and all its non-shaded dependencies which are listed in our pom.xml [1] to your class path (project class path in eclipse - Java class path if you launch your application from command line).

For example:

org.apache.lucene
lucene-core
4.6.1

[1] http://search.maven.org/remotecontent?filepath=org/elasticsearch/elasticsearch/1.0.1/elasticsearch-1.0.1.pom

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

Le 19 mars 2014 à 14:40:12, Venu Krishna (yvgk2010@gmail.com) a écrit:

Hi David,i will make it simple.My main moto is using java i want to do CRUD operations with ElasticSearch,in this process i came to know about ElasticSearch related Java
Api's URL : http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/index.html ,from this i followed the steps as it is starting from Maven to Client Api.I am using Eclipse Kepler and created WebDynamic Project and build the respective jars,and copied the code from Client Api(Node based and TransportClient) and execute using JavaApplication i.e.main() which uses console app i.e. eclipse cmd. so,for now am trying atleast to connect to Elasticsearch ,after getting this then i will move on with CRUD operations using JSON. ANY GUIDANCE GIVEN WILL BE HIGHLY APPRECIATED.

URGENT REQUIREMENT.
Thanks in advance.
On Wednesday, March 19, 2014 2:48:37 PM UTC+5:30, Venu Krishna wrote:
Hi can any body give me the code or steps to communicate elasticsearch using java.I ahve already created one example,but i am not able to understand what it is doing, is there any source code or step by step creation of example in eclipse Using Transoprt Client as well as Node .

here is the code which i found in google and try to execute.

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.elasticsearch.client.Client;
import org.elasticsearch.node.Node;

import static org.elasticsearch.node.NodeBuilder.*;

public class PostES {

public static void main (String args[]){
    PostES p = new PostES();
    p.postElasticSearch();
}


public static Map<String, Object> putJsonDocument(String title, String content, Date postDate, String author){

        Map<String, Object> jsonDocument = new HashMap<String, Object>();

        jsonDocument.put("title", title);
        jsonDocument.put("conten", content);
        jsonDocument.put("postDate", postDate);
        jsonDocument.put("author", author);

        return jsonDocument;
}


private void postElasticSearch(){

        Node node    = nodeBuilder().node();
        Client client   = node.client();

        client.prepareIndex("testindex", "article")
                  .setSource(putJsonDocument("Example Title",
                                             "This description is so important. You dont even know!",
                                             new Date(),
                                             "J.R."))
                                             .execute().actionGet();

        node.close();
    }

}

and i am getting errors as

Exception in thread "main" org.elasticsearch.common.inject.internal.ComputationException: org.elasticsearch.common.inject.internal.ComputationException: java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:553)
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at org.elasticsearch.common.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at org.elasticsearch.common.inject.internal.FailableCache.get(FailableCache.java:46)
at org.elasticsearch.common.inject.ConstructorInjectorStore.get(ConstructorInjectorStore.java:52)
at org.elasticsearch.common.inject.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:57)
at org.elasticsearch.common.inject.InjectorImpl.initializeBinding(InjectorImpl.java:377)
at org.elasticsearch.common.inject.BindingProcessor$1$1.run(BindingProcessor.java:169)
at org.elasticsearch.common.inject.BindingProcessor.initializeBindings(BindingProcessor.java:224)
at org.elasticsearch.common.inject.InjectorBuilder.initializeStatically(InjectorBuilder.java:120)
at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:105)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:92)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:69)
at org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:58)
at org.elasticsearch.node.internal.InternalNode.(InternalNode.java:146)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)
at PostES.postElasticSearch(PostES.java:33)
at PostES.main(PostES.java:14)
Caused by: org.elasticsearch.common.inject.internal.ComputationException: java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:553)
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:419)
at org.elasticsearch.common.inject.internal.CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041)
at org.elasticsearch.common.inject.internal.FailableCache.get(FailableCache.java:46)
at org.elasticsearch.common.inject.MembersInjectorStore.get(MembersInjectorStore.java:66)
at org.elasticsearch.common.inject.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:69)
at org.elasticsearch.common.inject.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:31)
at org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:39)
at org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:35)
at org.elasticsearch.common.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:549)
... 18 more
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/lucene/store/Lock;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.lang.Class.getDeclaredFields(Unknown Source)
at org.elasticsearch.common.inject.spi.InjectionPoint$Factory$1.getMembers(InjectionPoint.java:386)
at org.elasticsearch.common.inject.spi.InjectionPoint$Factory$1.getMembers(InjectionPoint.java:384)
at org.elasticsearch.common.inject.spi.InjectionPoint.addInjectorsForMembers(InjectionPoint.java:359)
at org.elasticsearch.common.inject.spi.InjectionPoint.addInjectionPoints(InjectionPoint.java:353)
at org.elasticsearch.common.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:295)
at org.elasticsearch.common.inject.MembersInjectorStore.createWithListeners(MembersInjectorStore.java:78)
at org.elasticsearch.common.inject.MembersInjectorStore.access$000(MembersInjectorStore.java:35)
at org.elasticsearch.common.inject.MembersInjectorStore$1.create(MembersInjectorStore.java:43)
at org.elasticsearch.common.inject.MembersInjectorStore$1.create(MembersInjectorStore.java:40)
at org.elasticsearch.common.inject.internal.FailableCache$1.apply(FailableCache.java:35)
at org.elasticsearch.common.inject.internal.MapMaker$StrategyImpl.compute(MapMaker.java:549)
... 28 more
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.store.Lock
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 42 more

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/ee2e8cf8-7b69-4493-8e87-c7517be8c4ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.5329a3e7.1f48eaa1.97ca%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.