You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "ldqk (via GitHub)" <gi...@apache.org> on 2025/05/07 02:24:26 UTC
[I] MultiFieldQueryParser set boosts parameter does not works [lucenenet]
ldqk opened a new issue, #1157:
URL: https://github.com/apache/lucenenet/issues/1157
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
``` csharp
var query = new MultiFieldQueryParser(Lucene.Net.Util.LuceneVersion.LUCENE_48, fields, analyzer, new Dictionary<string, float>
{
{ "title", 2.0f }, // set 2.0 or 1.0,the following result docs Score property is the same
{ "keyword", 1.0f }
}).Parse("ldqk");
var sort = new Sort([new SortField("title",SortFieldType.STRING)]);
var docs = indexSearcher.Search(query, filter,10, sort, true, true).ScoreDocs;
```
### Expected Behavior
Set the different boosts parameter,the docs Score is different
### Steps To Reproduce
_No response_
### Exceptions (if any)
_No response_
### Lucene.NET Version
4.8.0-beta00017
### .NET Version
.NET 9
### Operating System
Windows 11
### Anything else?
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] MultiFieldQueryParser set boosts parameter does not works [lucenenet]
Posted by "paulirwin (via GitHub)" <gi...@apache.org>.
paulirwin commented on issue #1157:
URL: https://github.com/apache/lucenenet/issues/1157#issuecomment-3222469446
@ldqk After an investigation and testing, the MultiFieldQueryParser boost functionality seems to be working correctly in both 4.8.0-beta00017 and latest master.
I created a test case that verifies both the query string representation and actual document scoring with different boost values. The test confirms that when different boost values are applied to fields, the resulting document scores do change accordingly. Documents matching in fields with higher boost values receive proportionally higher scores, which is the expected behavior.
The test demonstrates that when setting a boost of 2.0f for the "title" field and 1.0f for the "keyword" field, documents with matches in the title field score higher than when the boosts are reversed. So it does seem to be working as expected.
During the investigation, I did identify and fix a minor issue where the boost dictionary was accessed directly without checking if the key exists first, which could potentially cause exceptions in certain scenarios. This has been corrected to use TryGetValue for safer dictionary access.
The boost functionality in Lucene.NET appears to be working identically to the Java Lucene 4.8.1 implementation. If you're still experiencing issues with boost values not affecting scores, please verify that the boost dictionary is being properly initialized with the correct field names that match exactly with the fields being searched, as field name mismatches would result in boosts not being applied. Or please provide a more comprehensive example demonstrating what exactly does not work as expected. Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] MultiFieldQueryParser set boosts parameter does not works [lucenenet]
Posted by "paulirwin (via GitHub)" <gi...@apache.org>.
paulirwin closed issue #1157: MultiFieldQueryParser set boosts parameter does not works
URL: https://github.com/apache/lucenenet/issues/1157
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org