Search Lucene.NET 4.8 does not return results

After upgrading from Lucene 3.X to 4.8, I had to rewrite a couple of things to make things work again.

I tried several complete solutions (taking into account our situation) from different tutorials, as well as many different settings and tests, but I can not find what the real problem is with the code below.

Starting with code

The code for adding fields to the document now looks like this: after changing fields from general types to a specific row type

Document document = new Document
{
    new StringField("productName", product.Name, Field.Store.YES),
    new StringField("productDescription", product.Description, Field.Store.YES),
    new StringField("productCategory", product.Category, Field.Store.YES)
};

The search part of the code is as follows:

Analyzer analyzer = new StandardAnalyzer(Version);
IndexReader reader = DirectoryReader.Open(indexDirectory);
IndexSearcher searcher = new IndexSearcher(reader);
MultiFieldQueryParser parser = new MultiFieldQueryParser(Version,
    new[] { "productName", "productCategory", "productDescription" },
    analyzer,
    new Dictionary<string, float> {
        { "productName", 20 },
        { "productCategory", 5 },
        { "productDescription", 1 }
    }
); 

ScoreDoc[] hits = searcher.Search(parser.Parse(searchTerm))?.ScoreDocs;

Problem

When searching for only a wildcard, the search returns everything correctly, so part of the indexing works fine. If, however, I try to find the next product with any search term, nothing was found at all.

  • : Tafelrok
  • : Tafelrok
  • : Tafels Stoelen

'Tafelrok', 'tafelrok', 'Tafel', 'tafel', 'afel', 'afe' .. 3 , - .

parser.Parse(searchTerm), ( "+ searchTerm +" "), .

- , , ?

+6
1

, .

StringField - , , ( ). StandardAnalyzer . , KeywordAnalyzer . (, ), TextField. , (* ?).

:

+2

All Articles