Phrase queries with shingles
Imagine that you have an application that searches within millions of documents that are generated by a law company. One of the requirements is to search boost the documents that have either a search phrase or part of the phrase in their title. So, is it possible to achieve it using Solr? Yes, and this recipe will show you how to do this.
How to do it...
Let's follow these steps to achieve this:
Let's start with our index structure; we configure it 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" />
The second step is to create example data that looks like this:
<doc> <field name="id">1</field> <field name="title">Financial report 2014</field> </doc> <doc> <field name="id">2</field> <field name="title">Financial marketing report 2014...