简体   繁体   English

确定哪个值在SOLR多值字段type2中产生了匹配

[英]determine which value produced a hit in SOLR multivalued field type2

See also: determine which value produced a hit in SOLR multivalued field type 另请参见: 确定哪个值在SOLR多值字段类型中产生了匹配

This question has been asked and has been answered on Jan 2010. 有人问过这个问题,并在2010年1月得到了回答。

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. 对于新的Solr版本,最新的稳定版本是3.5.0,是否存在任何Solr功能来标识导致命中的多值字段。

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 ? 有没有办法我知道值Term1和Term2是从Solr返回的结果中引起点击的?

Something you could try is playing with Analyzer#getPositionIncrementGap and IndexReader#getTermVectors to compute which field1 instance contained Term . 您可以尝试使用Analyzer#getPositionIncrementGapIndexReader#getTermVectors来计算哪个field1实例包含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 . 例如,如果您的field1实例少于10个,并且每个实例的术语少于100个,则使用positionIncrementGap * IncrementGap为10 * 100 = 1000可以帮助您使用position % 1000来计算哪个字段包含Term

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. 请注意,这是一个hack,尽管我可以将其用于测试,但我可能不会在任何严肃的软件中这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM