Lucene field boosting not working for search index fields


Description

Sometimes it is required to add or modify boost values for certain fields in the search index. For example, this can be done by changing this definition:

<field fieldName="parsedlanguage" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" ...>

to this:

<field fieldName="parsedlanguage" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="2f" type="System.String" ...>

As a result, when running search queries against the field in question, you may notice that the field boosting value remains 1f and the search results are not sorted according to the configured parameters.

This happens due to an issue with search configuration parser not being able to process numbers with letters such as 2f, and falling back to the default value which is 1f.

To read more about scoring and boosting in Lucene, use the following article:
http://lucene.apache.org/core/3_6_2/scoring.html

Solution

To solve the issue, specify the boosting value using a floating point format like below:

<field fieldName="parsedlanguage" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="2.0" type="System.String" ...>