Solr Lucene在多值字段中查找索引?

Solr Lucene在多值字段中查找索引?,solr,lucene,solarium,Solr,Lucene,Solarium,我有一个名称的多值字段,我必须在列表中找到匹配值的索引 DOC example: profile_id: 1 names: [ "My name", "something", "My second name", "My nickname"] 查询: profile_id:1 AND names:"My secon name"~ 预期结果: my doc, and the index of the matched, 2 可能吗?与TermQuery一样匹配文档,但它也跟踪出现在同一文档中的

我有一个名称的多值字段,我必须在列表中找到匹配值的索引

DOC example:

profile_id: 1
names: [ "My name", "something", "My second name", "My nickname"]
查询:

profile_id:1 AND names:"My secon name"~
预期结果:

my doc, and the index of the matched, 2
可能吗?

与TermQuery一样匹配文档,但它也跟踪出现在同一文档中的相同术语的位置

Spans positionInfoForAllMatchingDocs = spanQuery.getSpans(..arguments..);
int position = -1;
while(positionInfoForAllMatchingDocs.next()){
      position = positionInfoForAllMatchingDocs.start() // Returns the start position of the current match.
      System.out.println("Found match in the document with id: " + positionInfoForAllMatchingDocs.doc() + " at position: " + position); // You obviously want to replace this sysout with something elegant.
}
  • 确保计划检索位置信息的字段已使用field.TermVector.with_POSITIONS或field.TermVector.with_POSITIONS和_offset编制索引
您是否尝试过此查询?因为多值字段的处理方式相同。可能您需要澄清问题到底出了什么问题?Expected result表示我需要的,而响应只是文档,不知道哪个名称的索引匹配MultifieldQueryParser-允许您指定所需的名称。此外,此链接(我从未尝试过)谈到所有字段,“索引”这个词是非常模糊的,因为“索引”这个词在Lucene中主要用于反向索引。我相信你正在寻找匹配术语的“位置”,对吗?