I have to move from High Level REST client to Java API Client
I would like to show one method I have to replace and learn from that . This is old method:
public List<Map<String, Object>> getPublicFilters() {
SearchRequest searchRequest = new SearchRequest("filter-template");
searchRequest.source(new SearchSourceBuilder().query(QueryBuilders.matchQuery("private", false)));
return Arrays.stream(client.get().search(searchRequest, RequestOptions.DEFAULT).getHits().getHits())
.map(SearchHit::getSourceAsMap).collect(Collectors.toList());
}
I understand it have to be replaced to something like this:
indexName is probably "filter-template"
and I assume "route" have to be replaced with "private"
but what about searchText ?
And Flight.class - is it Object in ma case ?
and I assume "route" have to be replaced with "private"
Yes.
but what about searchText ?
I believe it should be false. But I'd use a term query instead of a match query as I guess your field is mapped as a boolean...
And Flight.class - is it Object in ma case ?
I'd recommend it to be your Java Bean (the business object). That's one of the cool additions of this Java client. You can directly index your java beans and get back your java beans at search time...
You should not start a new project with that one for sure.
If you are planning to use 8.x, switch to it. I don't think the HLClient will be able to support it and actually a lot of new APIs are not available in the HLClient.
In general, I'd recommend:
Upgrade your 7.x or below cluster to 7.17.x
Switch to the new Java API Client with the 7.17.x version
Then, when possible, upgrade your client and cluster to 8.x (the latest version)
I said that you should not. Not that you can't... I'd really avoid it if possible.
This setting has been made for existing code when people want to upgrade the cluster to 8.x but don't have time to rewrite the code using the new Java API Client.
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.