[
https://issues.apache.org/jira/browse/LUCENENET-519?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Christopher Currens closed LUCENENET-519.
-----------------------------------------
Resolution: Won't Fix
This is a known behavior with the NumericField, and AFAIK, still exists in
Java's code for 4.0. The offending bit of code is on line 206:
{{public NumericField(System.String name, int precisionStep, Field.Store store,
bool index):base(name, store,
index?*Field.Index.ANALYZED_NO_NORMS*:Field.Index.NO, Field.TermVector.NO)}}
When indexing a NumericField, it is specifically analyzed with no norms, which
means that index-time boosting cannot be applied. It's done with no warning,
which is why it seems like a bug. This behavior (the warning of trying to set
a boost value on a field omitting norms) was changed around a year ago in the
Java code. (See
[LUCENE-3796|https://issues.apache.org/jira/browse/LUCENE-3796]).
For at least the 3.x branch, I don't think this behavior will change, since
we're trying to keep it as close to the java implementation as possible. Since
NumericField is just a thin wrapper around a NumericTokenStream, use a
different Field overload instead and then manually set the token stream:
{code}
var numericField = new Field("regular", string.Empty, Field.Store.YES,
Field.Index.ANALYZED) { Boost = 1F };
numericField.SetTokenStream(new
NumericTokenStream(NumericUtils.PRECISION_STEP_DEFAULT).SetIntValue(1));
numericField.OmitTermFreqAndPositions = true;
doc.Add(numericField);
{code}
You can use the Field constructor overload that takes in a token stream, but
that way, it won't store the field.
> NumericField.Boost ignored at index time
> ----------------------------------------
>
> Key: LUCENENET-519
> URL: https://issues.apache.org/jira/browse/LUCENENET-519
> Project: Lucene.Net
> Issue Type: Bug
> Components: Lucene.Net Core
> Affects Versions: Lucene.Net 3.0.3
> Reporter: Chris Eldredge
> Priority: Minor
> Attachments: NumericFieldBoostTests.cs
>
>
> When adding a document that contains a NumericField with a boost value
> greater than 1.0f (the default), the boost value seems to be ignored.
> Querying later using a BooleanQuery does not boost the numeric field over
> other fields that have a default boost amount.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira