Affecting document score using function queries
There are many situations where you would like to have an influence on how the score of the documents is calculated. For example, you would like to boost the documents on the basis of the purchases of it. As in, as an e-commerce bookstore, you would like to be showed relevant results, but you would also like to influence them by adding yet another factor to their score. Is this possible? Yes, and this recipe will show you how to do it.
How to do it...
Let's see how the document score is affected using function queries and the following steps:
Let's start by defining the index structure by adding the following section to the
schema.xml
file:<field name="id" type="string" indexed="true" stored="true" required="true" /> <field name="title" type="text_general" indexed="true" stored="true" /> <field name="sold" type="int" indexed="true" stored="true" />
The second step will be the example data, which looks like this:
<add> <...