Recommended search in SOLR
One of the nice features of SOLR is the ability for doing promoted or recommended searches.
With this feature, you can basically use a kind of query (elevation query), that is able to elevate static searches configured by id.
Use case example: Imagine that you have a popular Alfresco blog in your site, and you want that when searching for term «alfresco blog», your first or just a «recommended page» is the solutions page.
In elevate.xml:
<elevate> <query text="alfresco blog"> <doc id="https://www.zylk.net/es/solutions/alfresco" /> </query> </elevate>
In your solrconfig.xml:
<searchComponent name="elevator" class="solr.QueryElevationComponent" > <!-- pick a fieldType to analyze queries --> <str name="queryFieldType">string</str> <str name="config-file">elevate.xml</str> <str name="editorialMarkerFieldName">elevated</str> </searchComponent>
Then in the fl parameter of your query should include the field «[elevated]«. Using solr admin with qt=/elevate or the bash script of the other day:
$ ./do-search.sh "alfresco blog" url,score,[elevated] "" elevate zylk
It is clear that if you order by score, you can see something diferent in the resultset.
{ "url": "https://www.zylk.net/es/solutions/alfresco", "score": 0, "[elevated]": true } { "url": "https://www.zylk.net/alfresco-blog", "score": 2.7496874, "[elevated]": false } { "url": "https://www.zylk.net/es/web-2-0/blog/-/categories/36541", "score": 2.3795006, "[elevated]": false }
Links:
- https://www.zylk.net/es/web-2-0/blog/-/blogs/playing-with-solr-cloud-and-rest-api-
- https://lucene.apache.org/solr/guide/6_6/the-query-elevation-component.html#TheQueryElevationComponent-TheexclusiveParameter
- http://lucene.472066.n3.nabble.com/quot-editorialMarkerFieldName-quot-td4373959.html
- https://issues.apache.org/jira/browse/SOLR-11977