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

Reply via email to