我有一个多值的名称字段,我必须在列表中找到匹配值的索引。
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
可能吗?
SpanTermQuery与 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.
}