Ok, i am looking at using ElasticSearch, via Java, for one of my applications,
and have installed version 5.0.0 and have it running ok, in about 10 mins
i have now copied, the Jar file down, into my test app, (netbeans is my development environment 8.0.2) , using start Jar file elasticsearch-5.0.0.jar no marven
and using the example from the docs/web page
public static void main(String[] args)
{
TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(""), 9300));
client.close();
}
and i am getting a comple error on PreBuiltTransportClient, and it does not apper to be in the Jar files, or am i missing some thing.
or is there another example else where, that does not use "PreBuiltTransportClient"
Ok so I'm having the same problem. I've added the transport library through the pom entry shown, but the reference to Settings.EMPTY is complaining that it can't be resolved. Next idea?
I'm using Eclipse, and have refreshed the project, forced clean several times. The portion of text of the example with the problem is:
TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
The word EMPTY is highlighted and when I hover over it this is the exact message:
"EMPTY cannot be resolved or is not a field"
This is generally the message when the object definition doesn't exist in the project.
However, if I purposefully change the reference to something else, such as "EMPTYS", in addition to getting the same message (e.g., "... cannot be resolved or is not a field") it does prompt me to change it to "EMPTY_PARAMS". When I do that, however, then the error changes to highlight the entire constructor statement:
new PreBuiltTransportClient(Settings.EMPTY_PARAMS)
and says "The constructor PreBuiltTransportClient(ToXContent.Params) is undefined"
My imports in this class include:
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
I changed the version to 5.0.2 (although just last night the example gave me 5.0.1 as the version to use - fyi). Same problem. Then as I was trying to create a settings object directly, I discovered that there was some weird conflict between your code and the version of SpringBoot I had been trying to use (1.3.5). I upgraded to 1.4.2 and made a few other adjustments (had an unrelated LOGGER issue with the change) and now your code compiles and I can run the demonstration. Thanks for the hint...
I spoke too soon. While I compiled correctly, I'm getting a run time error now about
Exception in thread "main" java.lang.NoSuchMethodError: org.elasticsearch.client.transport.TransportClient.<init>(Lorg/elasticsearch/common/settings/Settings;Lorg/elasticsearch/common/settings/Settings;Ljava/util/Collection;Lorg/elasticsearch/client/transport/TransportClient$HostFailureListener;)V
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:92)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:81)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:71)
at com.eab.certified.App.testPutAndGet(App.java:94)
at com.eab.certified.App.main(App.java:58)
This is happening right at the same line of code:
TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9200));
Ok, now I think I have it. I might suggest that the demo example include a bit more details. I had stitched together things from several different places, and what finally worked was having the following settings in my pom. I'm in business finally!
I am getting below error can you pls here, Elastic search jar Version used 5.1.1
SEVERE: Servlet.service() for servlet [issuetracker] in context with path [/issuetracker] threw exception [Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.elasticsearch.transport.client.PreBuiltTransportClient.addPlugins(Ljava/util/Collection;Ljava/util/Collection;)Ljava/util/Collection;] with root cause
java.lang.NoSuchMethodError: org.elasticsearch.transport.client.PreBuiltTransportClient.addPlugins(Ljava/util/Collection;Ljava/util/Collection;)Ljava/util/Collection;
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:92)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:81)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:71)
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.