I have created a search engine using solr. I want to create a query such that if the user searches for the word "college", the score of the document which has the word "famous" in close proximity (within 2 words ie "famous college" or "college is famous") should be higher. If the word famous is not present in close proximity then it should calculate score based on the word "college" only.
What I want is something like this "famous college"~2^10 OR "college famous"~1^10 OR "college"
How to achieve this in eDismax?
What you are looking for is called a phrase search with a phrase slop of 2. For example setting defaults in
solrconfig.xml
might look something like:Controlling the phrase search in the query might look like:
More information on phrase queries using eDismax can be found in the Solr Reference page for eDismax.