ElasticSearch Solr equivalent getBeans

I am trying to switch from Solr to Elasticsearch, I am converting some classes that I worked with Solr to Elasticsearch, but right now I am stuck with this.

In Solr, I had:

QueryResponse response = getServer().query(myQuery);
List<MyClass> result = response.getBeans(MyClass.class);

and that’s all, I got a list with MyClass objects that I could use, but I did not find the equivalent for getBeans in the jastic API ElasticSearch, is there something similar or do I need to get the source of the result using

searchHit.getSourceAsString();

or

searchHit.getSource();

and analyze the result to create your own bean?

Any help or pointer in the right direction would be greatly appreciated.

Thank.

+5
source share
1 answer

Elasticsearch allows you to read the entire source in different formats, among which the most interesting for you are:

  • String SearchHit#sourceAsString
  • Map<String, Object> SearchHit#sourceAsMap

, : , lucene , . Map<String, SearchHitField> SearchHit#fields.

Elasticsearch json, Solr, json-. , Java SearchHit Java API. osem project, , , - , , , , .

Json Java, . elasticsearch .

Java API Jest client, , POJO. , Rest elasticsearch Java API, . elasticsearch .

+5

All Articles