Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The current algorithm uses the proximity query type as mentioned in the Apache SOlr Wiki, however as per Nick_vh there may be a better solution. Copy-pasta-ing here so we can discuss how we can implement this into the module.
<requestHandler name="/closer" class="solr.StandardRequestHandler">
<lst name="defaults">
<str name="q">_query_:"{!dismax qf=$qfQuery mm=1 pf=$pfQuery bq=$boostQuery v=$q}"</str>
<str name="qfQuery">title</str>
<str name="pfQuery">title^1000</str>
<str name="boostQuery">_query_:"{!dismax qf=$boostQueryQf mm=100% v=$mainQuery}"^100</str>
<str name="boostQueryQf">title</str>
<str name="df">title</str>
</lst>
</requestHandler>
Usage:
http://localhost:8983/solr/closer?mainQuery=solr+cookbook&fl=score,id,title
From Nick,
Query for words that are closer to each other (term proximity). I wonder if we can rewrite this so we don't need a special handler