Boosting fields in Zend Search Lucene
-
01-03-2021 - |
Question
When I look at the Zend framework documentation, Zend Search Lucene has the ability to boost search terms.
Is there a way to boost fields? That is, make hits in a field more relevant than others?
Example:
Document1
Name: Jane Doe
Description: Wife of John Doe
Document2
Name: John Doe
Description: Husband of Jane Doe
Search query = "John Doe"
In this example, I want to boost "Name" field because it is more relevant. The search results should list Document2 first rather than Document1
Solution
Yes, use the setBoost method of the field. (I'm not familiar with Zend's implementation, but I assume they have an equivalent method.)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow