5/29/2023 0 Comments Apache lucene query exact match![]() ![]() These implementations can be combined in a wide variety of ways to provide complex querying capabilities along with information about where matches took place in the document collection. add public void add ( Term term) Adds a term to the end of the query phrase. In this regard, Lucene offers a wide variety of Query implementations, most of which are in the package. getSlop public int getSlop () Returns the slop. The slop is zero by default, requiring exact matches. Try a PhraseQuery instead: PhraseQuery query = new PhraseQuery() Įdit: I think you have a different problem. More exact matches are scored higher than sloppier matches, thus search results are sorted by exactness. SpanNearQuery query = new SpanNearQuery(clause, 0, true) īooleanQuery.add(query, ) SpanTermQuery clause = new SpanTermQuery Ĭlause = new SpanTermQuery(new Term("contents",word)) Searching String sentence = searchParameters.get("searchExactWord") ![]() ![]() Indexing IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(Version.LUCENE_30), false,) ĭoc.add(new Field("contents", sb.toString(),, ,_POSITIONS_OFFSETS)) ĭoc.add(new Field("imageid", imageDocument.getImageId(),, _ANALYZED)) ĭoc.add(new Field("title", imageDocument.getTitle(),, )) ĭoc.add(new Field("country", imageDocument.getCountry(),, _ANALYZED)) For example, you can use the Boolean operators AND, OR, and NOT to search for. I am using SpanTerm Query for searching exact phrase in lucene. When entering advanced syntax, select Exact Match as the Search Method. ![]()
0 Comments
Leave a Reply. |