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.