user3156792
user3156792

Reputation: 79

Using elasticsearch Java API

I am very new to elasticsearch. I found some simple java code for using elasticsearch:

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

// on startup

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

// on shutdown

node.close();

I am getting the following error:

package org.elasticsearch.node doesn't exist

Later, I found that I have put some information in pom.xml. What is that? How to make this simple program run?

Upvotes: 2

Views: 4533

Answers (1)

dadoonet
dadoonet

Reputation: 14492

Do you know what Maven is?

I mean that if you are using Maven, then you need to add elasticsearch-VERSION.jar as a dependency in your pom.xml.

If not, then you need to add elasticsearch jar in your project classpath and some other libs such as (it depends of elasticsearch version you are using):

  • antlr-runtime-3.5.jar
  • asm-4.1.jar
  • asm-commons-4.1.jar
  • jna-3.3.0.jar
  • jts-1.12.jar
  • log4j-1.2.17.jar
  • lucene-analyzers-common-4.6.0.jar
  • lucene-codecs-4.6.0.jar
  • lucene-core-4.6.0.jar
  • lucene-expressions-4.6.0.jar
  • lucene-grouping-4.6.0.jar
  • lucene-highlighter-4.6.0.jar
  • lucene-join-4.6.0.jar
  • lucene-memory-4.6.0.jar
  • lucene-misc-4.6.0.jar
  • lucene-queries-4.6.0.jar
  • lucene-queryparser-4.6.0.jar
  • lucene-sandbox-4.6.0.jar
  • lucene-spatial-4.6.0.jar
  • lucene-suggest-4.6.0.jar
  • spatial4j-0.3.jar

I'd recommend to use Maven because it's much easier to deal with dependencies.

Hope this helps

Upvotes: 5

Related Questions