Lucene.net Boost does not work when using * wildcard

I have two documents and I use Luke for research, I confirmed in the code that it has the same behavior using StandardAnalyzer .

Document one with boost 1

 stored/uncompressed,indexed,tokenized<Description:Nummer ett> stored/uncompressed,indexed,tokenized<Id:2> stored/uncompressed,indexed,tokenized<Name:Apa> 

Document two with boost 2

 stored/uncompressed,indexed,tokenized<Description:Nummer tvΓ₯> stored/uncompressed,indexed,tokenized<Id:1> stored/uncompressed,indexed,tokenized<Name:Apa> 

Finding apa in the Name field Returns using boost and in the correct order.

 Document 2 has Score 1,1891 Document 1 has Score 0.5945 

Search ap * Returns the same score in any order

 Document 1 Score 1.0000 Document 2 Score 1.0000 

Search apa * Returns the same score in any order

 Document 1 Score 1.0000 Document 2 Score 1.0000 

Why is this? I would like to return some documents with a higher boost value, even if I have to use wildcards. Is it possible?

Greetings to all the cool coders!

This is what I want to do.

Search string and need matches. Using wildcards. Search "Lu" + "*"

 Document Name City 

I would like a document whose name Lund to get a higher rating than a document named Lunt or City, for example, Lund. This is due to the fact that I will know which documents are the most popular. I want to get documents with the city of Stockholm and call Stockholm and Stockholm, but ordered as I choose.

+8
c # lucene
source share
1 answer

Since WildcardQuery is a subclass of MultiTermQuery , you get a constant score of 1.

If you check the definition of t.getBoost() :

t.getBoost () is an increase in the search time for the term t in q query as indicated in the query text (see query syntax) or the application calls setBoost (). Please note that in fact there are no direct APIs for accessing the increase of one word in a multi-user query, but rather several terms are presented in the request as multi TermQuery objects, and thus, raising the term in the request is possible by calling the getBoost () subquery

http://lucene.apache.org/core/old_versioned_docs/versions/3_0_1/api/core/org/apache/lucene/search/Similarity.html#formula_termBoost

One possible hack might be to set the rewrite method of the query analyzer:

 myCustomQueryParser.SetMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE) 
+10
source share

All Articles