Using the basic Java example, here: https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-search.html
And having the following Maven dependencies installed:
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>7.2.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.2.0</version>
</dependency>
The code from the URL above:
SearchResponse response = client.**prepareSearch**("index1", "index2")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(QueryBuilders.termQuery("multi", "test")) // Query
.setPostFilter(QueryBuilders.rangeQuery("age").from(12).to(18)) // Filter
.setFrom(0).setSize(60).setExplain(true)
.get();
Does not compile on the "perpareSearch" as you see bolded above and there does not seem to be another maven dependency the IDE can find (or me either...).
I am creating the client as instructed to in 7.2, like this:
RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(
new HttpHost("localhost", 9200, "http"),
new HttpHost("localhost", 9201, "http")));
If I use one of the older methods online, then the Client object itself has the compile problem.
I have these imports:
import org.apache.http.HttpHost;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.MatchQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
Thus, I've yet to find a totally working simple example.
Thanks for any suggestions what's off here.