I'm writing a Web Application that communicates with Solr and I am using Spring Data Solr + SolrJ to get the information in Java.
For the Solr query, I am using (e)DisMax with some options (for now, and maybe later I need to add other things):
SolrQuery query = new SolrQuery();
query.set("q", terms);
query.set("pf", "text^100");
query.set("qf", "text");
query.set("defType", "edismax");
query.setStart(pageable.getOffset());
query.setRows(pageable.getPageSize());
query.setHighlight(true).setHighlightSnippets(10);
query.setParam("hl.fl", "text");
For this structure I have build a bean in this way
@SolrDocument
public class Document {
@Field
private String id;
@Field
private String text;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
And I am going to execute the query:
response = solrTemplate.getSolrServer().query(query);
List<Document> beans = solrTemplate.convertQueryResponseToBeans(response, Document.class);
After that, in my Document object I find only "id" and "text". Is it possible to annotate the bean to get the Highlight too?
Looking on the net I have found very few examples of using Spring Data Solr + SorlJ.