Imagine you are a search expert at a leading e-commerce shop in your region. One day disaster strikes and your marketing department says that the search results are not good enough. They would like you to favor documents that have the exact phrase typed by the user over the documents that have matches for separate words. Can you do it? Of course you can, and this recipe will show you how to achieve it.
Before you start reading this task I suggest you read the How to search for a phrase not a single word recipe in this chapter. It will allow you to understand the recipe better.
I assume that we will be using the DisMax query parser, not the standard one. We will also use the same schema.xml
file that was used in the How to search for a phrase not a single word recipe in this chapter.
Let's start with our sample data file which looks like the following code:
<add> <doc> <field name="id">1</field> <field name...