Imagine a situation where you need to search for documents that are similar to those you have searched before using some keywords and have been rendered by Solr as a search result. We will continue with our music composition e-commerce portal that we have been using for demonstration purposes. In this section, we will understand how to get similar documents (in our case, music composition) in the search result along with the result set rendered by the user while searching for a keyword.
Let us start by adding the following index structure to the fields
section of our schema.xml
file:
<field name="wm_id" type="string" indexed="true" stored="true" required="true" /> <field name="wm_name" type="text" indexed="true" stored="true" termVectors="true" />
We will use the following example data to work with:
<add> <doc> <field name="wm_id">wm1</field> <field name="wm_name">Sonata solo flute<...