Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Lucene の近接検索では、検索される単語の順序は維持されません。
結果のドキュメントで word1 が常に word2 の前に来るように検索をフィルタリングする方法はありますか?
そのSpanNearQueryためがあります。
SpanNearQuery
http://lucene.apache.org/core/old_versioned_docs/versions/2_9_4/api/all/org/apache/lucene/search/spans/SpanNearQuery.html
SpanTermQuery tq1 = new SpanTermQuery(new Term("field", "word1")); SpanTermQuery tq2 = new SpanTermQuery(new Term("field", "word2")); SpanNearQuery spanNear = new SpanNearQuery(new SpanQuery[]{tq1,tq2}, 2, true);