2013-03-10 5 views
0

나는 여러 값 필드를 갖고 있으며 목록에서 일치하는 값의 인덱스를 찾아야합니다.Lucene 다중 값 필드에서 인덱스를 찾으십니까?

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 

인가?

+0

이 검색어를 사용해 보셨습니까? 다중 값 필드가 동일한 방식으로 처리 되었기 때문입니다. 정확히 무엇이 잘못 될지에 대한 질문을 명확히해야 할 필요가 있습니까? – Dewfy

+0

expetcted 결과는 필요한 것입니다. 대신 응답은 이름의 인덱스 중 어느 것이 일치하는지 모른 채 단순히 의사입니다. – rodi

+0

MultiFieldQueryParser - 필요한만큼 많은 이름을 지정할 수 있습니다. – Dewfy

답변

0

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. 
} 
  • 는 위치 정보를 검색하기 위해 계획하고있는 필드, Field.TermVector.WITH_POSITIONS 또는 Field.TermVector.WITH_POSITIONS_AND_OFFSETS으로 색인하고 있는지 확인합니다.
관련 문제