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 ?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.