Weight Multipliers
As mentioned in the schema documentation, Searchcraft indexes are configured with a weight_multipliers
object. This object contains a key-value pair for each field in the index. The key is the name of the field and the value is a floating point number. The number is a multiplier that is applied to the score of a document when that field is searched.
Why are weight multipliers useful?
Weight multipliers are useful when you want to give more or less importance to specific fields for the score ranking when performing a search. For example, if you have a field that contains the title of a document and another field that contains the body of the document, you may want to give more importance to the title field when searching. This can be achieved by setting the weight multiplier for the title field to a higher number than the body field. You can also set the weight multiplier to a number less than 1.0 to reduce the importance of a field. Our general recommendation is to keep the weight multiplier between 0.5 and 2.0 for most fields but this can vary depending on the use case and amount of fields configured as searchable by default. Title fields are generally set to 2.0 or higher and body fields are typically set to 0.6 while neutrally important fields are set to 1.0.
Why is this needed?
When multiple fields are configured for the default search fields it scores a match within each field at an equal level if the occurance count of the term is the same in both field. In actuality this may result in less relevant results because its likely more important to have a match in the title field than the body field but we still want results in the body field to be returned in our results.
Things To Consider
- Weight multipliers are only applied to fields marked a default search fields because they only matter when searching across multiple fields at once. Weight multipliers are not needed when utilizing a specific
field_name: search_term
query. - The minimum value for a weight multiplier is 0.1.