You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by "Simon, Richard T" <Ri...@hms.harvard.edu> on 2011/06/20 18:28:55 UTC
Highlighting map use unique key field?
Hi - A simple yes or no question, I think.
I want to retrieve highlighting result from a QueryResponse. I know to use the following:
Map<String, Map<String, List<String>>> highlighting = resp.getHighlighting();
Most of the examples I've seen use the document uid to extract the results like so:
String key = resultDec.getFieldValue(UID_FIELD);
Map<String, List<String>> map = highlighting.get(key);
I think this is the right way to go, however I did see one code example that did things a bit differently: They defined a field to query and then used that field as the id field, like so:
solrQuery.setParam("fl","query");
... peform query ...
String id = (String) resultDoc.getFieldValue("query");
Map<String,List<String>> highlightSnippets = queryResponse.getHighlighting().get(id);
Our documents have no unique field right now. I can create one rather easily. However, because of the above example, I've been asked to confirm that the map returned by highlighting requires/uses the unique key field defined in the schema.
So, yes or no: Does the highlighting map require a unique key field? ("yes" could mean "well there are obscure ways to avoid it, but using the unique key is easier/better/more common").
Thanks,
-Rich