Search code examples
solr

Solr LTR query not working even though the model and feature store is present?


I have configured LTR in my solr collection and I am able to see my feature and model file. To test things out I have kept only two features and a very basic model file. I have attached both the files. I am able to retrieve the features using the following query :

localhost:8983/solr/waterstest/query?q=:&fl=title,id,description,score,[features store=myWatersFeatureStore efi.boostedTitle=columns efi.boostedDescription=Heater]

The above works fine. I am able to retrieve the feature and the score with the data

The problem comes when I try to rerank the results with the uploaded model. Here are the queries I have tried to rerank the results

localhost:8983/solr/waterstest/query?q=title:columns&rq={!ltr model=myWatersModel reRankDocs=100 efi.boostedTitle=columns efi.boostedDescription=Heater}&fl=id,score

Response

{
  "responseHeader":{
    "zkConnected":true,
    "status":400,
    "QTime":28,
    "params":{
      "q":"title:columns",
      "fl":"id,score",
      "rq":"{!ltr model=myWatersModel reRankDocs=100 efi.boostedTitle=columns efi.boostedDescription=Heater}"}},
  "error":{
    "metadata":[
      "error-class","org.apache.solr.common.SolrException",
      "root-error-class","org.apache.solr.common.SolrException",
      "error-class","org.apache.solr.client.solrj.impl.BaseHttpSolrClient$RemoteSolrException",
      "root-error-class","org.apache.solr.client.solrj.impl.BaseHttpSolrClient$RemoteSolrException"],
    "msg":"Error from server at null: cannot find model myWatersModel",
    "code":400}}

There is nothing in logs just the same error there

org.apache.solr.client.solrj.impl.BaseHttpSolrClient$RemoteSolrException: Error from server at null: cannot find model myWatersModel
        at org.apache.solr.client.solrj.impl.Http2SolrClient.processErrorsAndResponse(Http2SolrClient.java:742)
        at org.apache.solr.client.solrj.impl.Http2SolrClient.request(Http2SolrClient.java:412)
        at org.apache.solr.client.solrj.impl.Http2SolrClient.request(Http2SolrClient.java:761)
        at org.apache.solr.client.solrj.SolrClient.request(SolrClient.java:1290)
        at org.apache.solr.handler.component.HttpShardHandler.request(HttpShardHandler.java:78)
        at org.apache.solr.handler.component.ShardRequestor.call(ShardRequestor.java:130)
        at org.apache.solr.handler.component.ShardRequestor.call(ShardRequestor.java:41)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at com.codahale.metrics.InstrumentedExecutorService$InstrumentedRunnable.run(InstrumentedExecutorService.java:180)
        at org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor.lambda$execute$0(ExecutorUtil.java:212)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

I am able to retrieve the model store also :

localhost:8983/solr/waterstest/schema/model-store

{
  "responseHeader":{
    "status":0,
    "QTime":1},
  "models":[{
      "name":"myWatersModel",
      "class":"org.apache.solr.ltr.model.LinearModel",
      "store":"myWatersFeatureStore",
      "features":[{
          "name":"isboostedTitle",
          "norm":{"class":"org.apache.solr.ltr.norm.IdentityNormalizer"}},
        {
          "name":"isboostedDescription",
          "norm":{"class":"org.apache.solr.ltr.norm.IdentityNormalizer"}}],
      "params":{"weights":{
          "isboostedTitle":0.4,
          "isboostedDescription":0.2}}}]}

If the feature query works and I am able to retrieve the model as well then why am I getting the model null error. I know the error handling part is not apt here so can someone help me to point out what all could have gone wrong here?

This is how the feature file looks like

[
  {
    "store" : "myWatersFeatureStore",
    "name" : "isboostedTitle",
    "class" : "org.apache.solr.ltr.feature.SolrFeature",
    "params" : { "q" :"{!field f=title}${boostedTitle}"  }
  },
  {
    "store" : "myWatersFeatureStore",
    "name" : "isboostedDescription",
    "class" : "org.apache.solr.ltr.feature.SolrFeature",
    "params" : { "q" :"{!field f=description}${boostedDescription}" }
  }
]

And the corresponding model file

{
  "store" : "myWatersFeatureStore",
  "name" : "myWatersModel",
  "class" : "org.apache.solr.ltr.model.LinearModel",
  "features" : [
    { "name" : "isboostedTitle" },
    { "name" : "isboostedDescription" }
  ],
  "params" : {
    "weights" : {
      "isboostedTitle" : 0.4,
      "isboostedDescription" : 0.2
    }
  }
}

Solution

  • As explained in comments section a collection reload was required becuase testing the same thing on a single core on techproducts worked however in case of collection a reload was needed for changes to take effect