Need to import lots of lucene libraries to run example code


(Morris Chang) #1

Hi,

I am using java to learn elasticsearch API. I tried to start from the index
api with the example code on website Resource page:

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

    IndexResponse response = client.prepareIndex("twitter", "tweet", "1"

)
.setSource(jsonBuilder()
.startObject()
.field("user", "kimchy")
.field("postDate", new Date())
.field("message", "trying out Elasticsearch"
)
.endObject()
)
.execute()
.actionGet();

My problem is that importing only the elasticsearch-1.2.2.jar is not
enough, and I need to go download .jar files like

org/apache/lucene/search/vectorhighlight/SimpleFieldFragList
org/apache/lucene/index/memory/MemoryIndex.............

to solve the java.lang.NoClassDefFoundError.

Is there a better efficient way to import all these required class files?
(instead of google all the jar files and add into eclipse libraries)

--
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/c688d658-0211-44f8-87f2-06ec9e4fe619%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Jörg Prante) #2

Use the Maven dependencies of the ES jar in the Maven repo to let the IDE
build and run your code.

If you want to run your code, you have to include all jars under the "lib"
folder in ES_HOME into your classpath. Maven knows about these dependencies
automatically.

Jörg

On Thu, Jul 17, 2014 at 6:52 PM, Morris Chang morrisc1102@gmail.com wrote:

Hi,

I am using java to learn elasticsearch API. I tried to start from the
index api with the example code on website Resource page:

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

    IndexResponse response = client.prepareIndex("twitter", "tweet",

"1")
.setSource(jsonBuilder()
.startObject()
.field("user", "kimchy")
.field("postDate", new Date())
.field("message", "trying out
Elasticsearch")
.endObject()
)
.execute()
.actionGet();

My problem is that importing only the elasticsearch-1.2.2.jar is not
enough, and I need to go download .jar files like

org/apache/lucene/search/vectorhighlight/SimpleFieldFragList
org/apache/lucene/index/memory/MemoryIndex.............

to solve the java.lang.NoClassDefFoundError.

Is there a better efficient way to import all these required class files?
(instead of google all the jar files and add into eclipse libraries)

--
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/c688d658-0211-44f8-87f2-06ec9e4fe619%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/c688d658-0211-44f8-87f2-06ec9e4fe619%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/CAKdsXoE3cUf_saJhdPbOisC--2%2BAA6aiJyh3pXdOKBhvsAjdcw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3