0
votes

See also: determine which value produced a hit in SOLR multivalued field type

This question has been asked and has been answered on Jan 2010.

With new Solr versions, the latest stable version being 3.5.0, Is there any Solr feature present to identify the multivalued field that has caused the hit.

For Ex: 
<field name="id">ID</field>
<field name="field1">Term1</field>
<field name="field1">value2</field>
<field name="field1">Term2</field>

If I perform a search,

qf=field1&q=Term

Is there a way I can know that the values Term1 and Term2 caused the hit from the result returned from Solr ?

1
Uh, fetch the value of the field itself? or depending on what you have in mind, fetching facets (see Solr faceting) may help.Jesvin Jose
What is your use case? Maybe a change in the schema would be more relevant than a solution to this particular question.jpountz

1 Answers

0
votes

Something you could try is playing with Analyzer#getPositionIncrementGap and IndexReader#getTermVectors to compute which field1 instance contained Term.

For example, if you have less than 10 field1 instances, and if every instance has less than 100 terms, then using a positionIncrementGap of 10*100=1000 will help you compute which field contained Term using position % 1000.

Please note that you must enable term vectors (with positions) at indexing time to be able to do this.

Beware that this is a hack, although I could use it for testing, I would probably not do this in any serious software.