<?xml version="1.0"?>
<oembed><version>1.0</version><provider_name>Aeologic Blog</provider_name><provider_url>https://www.aeologic.com/blog</provider_url><title>Learning To Rank - Ultimate Solr Guide - Aeologic Blog</title><type>rich</type><width>600</width><height>338</height><html>&lt;blockquote class="wp-embedded-content" data-secret="VS6DI2fJ7w"&gt;&lt;a href="https://www.aeologic.com/blog/learning-to-rank18-learning-to-rank/"&gt;Learning To Rank &#x2013; Ultimate Solr Guide&lt;/a&gt;&lt;/blockquote&gt;&lt;iframe sandbox="allow-scripts" security="restricted" src="https://www.aeologic.com/blog/learning-to-rank18-learning-to-rank/embed/#?secret=VS6DI2fJ7w" width="600" height="338" title="&#x201C;Learning To Rank &#x2013; Ultimate Solr Guide&#x201D; &#x2014; Aeologic Blog" data-secret="VS6DI2fJ7w" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"&gt;&lt;/iframe&gt;&lt;script&gt;
/*! This file is auto-generated */
!function(d,l){"use strict";l.querySelector&amp;&amp;d.addEventListener&amp;&amp;"undefined"!=typeof URL&amp;&amp;(d.wp=d.wp||{},d.wp.receiveEmbedMessage||(d.wp.receiveEmbedMessage=function(e){var t=e.data;if((t||t.secret||t.message||t.value)&amp;&amp;!/[^a-zA-Z0-9]/.test(t.secret)){for(var s,r,n,a=l.querySelectorAll('iframe[data-secret="'+t.secret+'"]'),o=l.querySelectorAll('blockquote[data-secret="'+t.secret+'"]'),c=new RegExp("^https?:$","i"),i=0;i&lt;o.length;i++)o[i].style.display="none";for(i=0;i&lt;a.length;i++)s=a[i],e.source===s.contentWindow&amp;&amp;(s.removeAttribute("style"),"height"===t.message?(1e3&lt;(r=parseInt(t.value,10))?r=1e3:~~r&lt;200&amp;&amp;(r=200),s.height=r):"link"===t.message&amp;&amp;(r=new URL(s.getAttribute("src")),n=new URL(t.value),c.test(n.protocol))&amp;&amp;n.host===r.host&amp;&amp;l.activeElement===s&amp;&amp;(d.top.location.href=t.value))}},d.addEventListener("message",d.wp.receiveEmbedMessage,!1),l.addEventListener("DOMContentLoaded",function(){for(var e,t,s=l.querySelectorAll("iframe.wp-embedded-content"),r=0;r&lt;s.length;r++)(t=(e=s[r]).getAttribute("data-secret"))||(t=Math.random().toString(36).substring(2,12),e.src+="#?secret="+t,e.setAttribute("data-secret",t)),e.contentWindow.postMessage({message:"ready",secret:t},"*")},!1)))}(window,document);
//# sourceURL=https://www.aeologic.com/blog/wp-includes/js/wp-embed.min.js
&lt;/script&gt;
</html><thumbnail_url>https://www.aeologic.com/blog/wp-content/uploads/2020/06/Learning-To-Rank-in-Solr-1.png</thumbnail_url><thumbnail_width>1080</thumbnail_width><thumbnail_height>622</thumbnail_height><description>With the&nbsp;Learning To Rank&nbsp;(or&nbsp;LTR&nbsp;for short) contrib module you can configure and run machine learned ranking models in Solr. The module also supports feature extraction inside Solr. The only thing you need to do outside Solr is train your own ranking model. Learning to Rank Concepts Re-Ranking Re-Ranking allows you to run a simple query for matching documents and then re-rank the top N documents using the scores from a different, more complex query. This page describes the use of&nbsp;LTR&nbsp;complex queries, information on other rank queries included in the Solr distribution can be found on the&nbsp;Query Re-Ranking&nbsp;page. Learning To Rank Models In information retrieval systems,&nbsp;Learning to Rank&nbsp;is used to re-rank the top N retrieved documents using trained machine learning models. The hope is that such sophisticated models can make more nuanced ranking decisions than standard ranking functions like&nbsp;TF-IDF&nbsp;or&nbsp;BM25. Ranking Model A ranking model computes the scores used to rerank documents. Irrespective of any particular algorithm or implementation, a ranking model&#x2019;s computation can use three types of inputs: parameters that represent the scoring algorithm features that represent the document being scored features that represent the query for which the document is being scored Feature A feature is a value, a number, that represents some quantity or quality of the document being scored or of the query for which documents are being scored. For example documents often have a &#x2018;recency&#x2019; quality and &#x2018;number of past purchases&#x2019; might be a quantity that is passed to Solr as part of the search query. Normalizer Some ranking models expect features on a particular scale. A normalizer can be used to translate arbitrary feature values into normalized values e.g., on a 0..1 or 0..100 scale. Training Models Feature Engineering The LTR contrib module includes several feature classes as well as support for custom features. Each feature class&#x2019;s javadocs contain an example to illustrate use of that class. The process of&nbsp;feature engineering&nbsp;itself is then entirely up to your domain expertise and creativity. Feature Class Example parameters External Feature Information field length FieldLengthFeature {"field":"title"} not (yet) supported field value FieldValueFeature {"field":"hits"} not (yet) supported original score OriginalScoreFeature {} not applicable solr query SolrFeature {"q":"{!func}&nbsp;recip(ms(NOW,last_modified)&nbsp;,3.16e-11,1,1)"} supported solr filter query SolrFeature {"fq":["{!terms f=category}book"]} supported solr query + filter query SolrFeature {"q":"{!func}&nbsp;recip(ms(NOW,last_modified),&nbsp;3.16e-11,1,1)",&nbsp;"fq":["{!terms f=category}book"]} supported value ValueFeature {"value":"${userFromMobile}","required":true} supported (custom) (custom class extending&nbsp;Feature) Normalizer Class Example parameters Identity IdentityNormalizer {} MinMax MinMaxNormalizer {"min":"0", "max":"50" } Standard StandardNormalizer {"avg":"42","std":"6"} (custom) (custom class extending&nbsp;Normalizer) Feature Extraction The ltr contrib module includes a&nbsp;[features&nbsp;transformer] to support the calculation and return of feature values for&nbsp;feature extraction&nbsp;purposes including and especially when you do not yet have an actual reranking model. Feature Selection and Model Training Feature selection and model training take place offline and outside Solr. The ltr contrib module supports two generalized forms of models as well as custom models. Each model class&#x2019;s javadocs contain an example to illustrate configuration of that class. In the form of JSON files your trained model or models (e.g., different models for different customer geographies) can then be directly uploaded into Solr using provided REST APIs. General form Class Specific examples Linear LinearModel RankSVM, Pranking Multiple Additive Trees MultipleAdditiveTreesModel LambdaMART, Gradient Boosted Regression Trees (GBRT) Neural Network NeuralNetworkModel RankNet (wrapper) DefaultWrapperModel (not applicable) (custom) (custom class extending&nbsp;AdapterModel) (not applicable) (custom) (custom class extending&nbsp;LTRScoringModel) (not applicable) Quick Start with LTR The&nbsp;"techproducts"&nbsp;example included with Solr is pre-configured with the plugins required for learning-to-rank, but they are disabled by default. To enable the plugins, please specify the&nbsp;solr.ltr.enabled&nbsp;JVM System Property when running the example: Uploading Features To upload features in a&nbsp;/path/myFeatures.json&nbsp;file, please run: To view the features you just uploaded please open the following URL in a browser: Example: /path/myFeatures.json Extracting Features To extract features as part of a query, add&nbsp;[features]&nbsp;to the&nbsp;fl&nbsp;parameter, for example: The output XML will include feature values as a comma-separated list, resembling the output shown here: Uploading a Model To upload the model in a&nbsp;/path/myModel.json&nbsp;file, please run: To view the model you just uploaded please open the following URL in a browser: Example: /path/myModel.json Running a Rerank Query To rerank the results of a query, add the&nbsp;rq&nbsp;parameter to your search, for example: The addition of the&nbsp;rq&nbsp;parameter will not change the output XML of the search. To obtain the feature values computed during reranking, add&nbsp;[features]&nbsp;to the&nbsp;fl&nbsp;parameter, for example: The output XML will include feature values as a comma-separated list, resembling the output shown here: External Feature Information The&nbsp;ValueFeature&nbsp;and&nbsp;SolrFeature&nbsp;classes support the use of external feature information,&nbsp;efi&nbsp;for short. Uploading Features To upload features in a&nbsp;/path/myEfiFeatures.json&nbsp;file, please run: To view the features you just uploaded please open the following URL in a browser: Example: /path/myEfiFeatures.json As an aside, you may have noticed that the&nbsp;myEfiFeatures.json&nbsp;example uses&nbsp;"store":"myEfiFeatureStore"&nbsp;attributes: read more about feature&nbsp;store&nbsp;in the&nbsp;LTR Lifecycle&nbsp;section of this page. Extracting Features To extract&nbsp;myEfiFeatureStore&nbsp;features as part of a query, add&nbsp;efi.*&nbsp;parameters to the&nbsp;[features]&nbsp;part of the&nbsp;fl&nbsp;parameter, for example: Uploading a Model To upload the model in a&nbsp;/path/myEfiModel.json&nbsp;file, please run: To view the model you just uploaded please open the following URL in a browser: Example: /path/myEfiModel.json Running a Rerank Query To obtain the feature values computed during reranking, add&nbsp;[features]&nbsp;to the&nbsp;fl&nbsp;parameter and&nbsp;efi.*&nbsp;parameters to the&nbsp;rq&nbsp;parameter, for example: Notice the absence of&nbsp;efi.*&nbsp;parameters in the&nbsp;[features]&nbsp;part of the&nbsp;fl&nbsp;parameter. Extracting Features While Reranking To extract features for&nbsp;myEfiFeatureStore&nbsp;features while still reranking with&nbsp;myModel: Notice the absence of&nbsp;efi.*&nbsp;parameters in the&nbsp;rq&nbsp;parameter (because&nbsp;myModel&nbsp;does not use&nbsp;efi&nbsp;feature) and the presence of&nbsp;efi.*&nbsp;parameters in the&nbsp;[features]&nbsp;part of the&nbsp;fl&nbsp;parameter (because&nbsp;myEfiFeatureStore&nbsp;contains&nbsp;efi&nbsp;features). Read more about model evolution in the&nbsp;LTR Lifecycle&nbsp;section of this page. Training Example Example training data and a demo&nbsp;train_and_upload_demo_model.py&nbsp;script can be found in the&nbsp;solr/contrib/ltr/example&nbsp;folder in the&nbsp;Apache lucene-solr Git repository&nbsp;(mirrored on&nbsp;github.com). This example folder is not shipped in the Solr binary release. Installation of LTR The ltr contrib module requires the&nbsp;dist/solr-ltr-*.jar&nbsp;JARs. LTR Configuration Learning-To-Rank is a contrib module and therefore its plugins must be configured in&nbsp;solrconfig.xml. Minimum Requirements Include the required contrib JARs. Note that by default paths are relative to the Solr core so they may need adjustments to your configuration, or an explicit specification of the&nbsp;$solr.install.dir.&lt;lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-ltr-d.*.jar" /&gt; Declaration of the&nbsp;ltr&nbsp;query parser.&lt;queryParser name="ltr" class="org.apache.solr.ltr.search.LTRQParserPlugin"/&gt; Configuration of the feature values cache.&lt;cache name="QUERY_DOC_FV" class="solr.search.LRUCache" size="4096" initialSize="2048" autowarmCount="4096" regenerator="solr.search.NoOpRegenerator" /&gt; Declaration [&hellip;]</description></oembed>
