Java – Lucene search even if it should return no results

I am creating a Lucene search application. I use multiple instances of different analyzers and indexwriters of their indexsearchers, but the returned search results are empty, even if I know that I have indexed the specific words I am searching for

This is my searchengine class constructor

this.indexers = new ArrayList<StandardIndexer>();
    this.indexers.add(new StandardIndexer(new StandardAnalyzer()));
    this.indexers.add(new StandardIndexer(new EnglishstemAnalyzer()));
    this.indexers.add(new StandardIndexer(new KeywordAnalyzer()));
    this.indexers.add(new StandardIndexer(new EnglishSynonymAnalyzer()));
    this.indexers.add(new StandardIndexer(new EnglishSynonymstemAnalyzer()));
    this.indexers.add(new StandardIndexer(new EnglishSynonymKeywordAnalyzer()));
    this.searchers = new ArrayList<StandardSearcher>();
    for (StandardIndexer indexer : this.indexers) {
        this.searchers.add(new StandardSearcher(indexer));
    }

Standardindexer and standardsearcher are the implementations of my indexer and searcher, because we can see that the instance of indexer is used to create indexsearcher, so the directory and type of analyzer used are also shared between indexer and searcher pairs

Solution

Your question is about a known error in unknown code

So I write general:

>You must use "almost" the same analyzer for indexing and searching Therefore, the tag in the final index (= stem after stem) must match the tag in the query. > Before searching for indexed documents, you must ensure that the submission is complete. > Note that the standard query parser splits words in white space You cannot search for tokens with spaces without extra work (escape whitespace, search with phrases..) > You can use Luke to view the index directory https://github.com/DmitryKey/luke

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>