Apache Solr Learning To Rank Tips And Tricks

This short blog post wants to help you managing learning to rank feature and model stores in Apache Solr. Here I will list for you the main commands, while in the next post I will recap the most common errors that can occur during the manipulation of feature and model stores.

Learning to rank feature store

List

A feature store is a container of features.
A model uses features from only one feature store.
A feature store can be used by many models.
The list of the avaialble feature stores in the collection1 collection, is available at:

https://localhost:8983/solr/collection1/schema/feature-store

The response looks like:

{
  "responseHeader": {
       "status": 0,
       "QTime": 160
  },
  "featureStores": [
      "first_store",
      "second_store"
  ]
}

Where first_store and second_store are the available feature stores present in collection1.

Upload

To upload a feature store to a feature-store of a specific collection, we use the following curl command.

For the collection1 collection:

curl -XPUT "https://localhost:8983/solr/collection1/schema/feature-store/" --data-binary "@features.json" -H "Content-type:application/json"

Where features.json is the file containing the features (the feature store we want to upload).

For example:

[
    {
        "store": "first_store",
        "name": "feature_1",
        "class": "org.apache.solr.ltr.feature.ValueFeature",
        "params": {
            "value": "${feature_1}",
            "required": false
        }
    },
    {
        "store": "first_store",
        "name": "feature_2",
        "class": "org.apache.solr.ltr.feature.ValueFeature",
        "params": {
            "value": "${feature_2}",
            "required": false
        }
    },
....

Here “store” is the name of the feature store in the feature-store. It will be visible, after the upload, in the feature-store list.

Delete

To delete a feature store called first_store from the collection1 collection:

curl -XDELETE "https://localhost:8983/solr/collection1/schema/feature-store/first_store"

Learning to rank model store

List

As mentioned before:
A model uses features from only one feature store.
A feature store can be used by many models.
The list of the available models in the collection1 collection, is at:

https://localhost:8983/solr/collection1/schema/model-store

And it is something like:

{
  "responseHeader":{
    "status":0,
    "QTime":188},
  "models":[{
      "name":"model_1",
      "class":"org.apache.solr.ltr.model.MultipleAdditiveTreesModel",
      "store":"first_store",
      "features":[{
          "name":"feature_1",
          "norm":{"class":"org.apache.solr.ltr.norm.IdentityNormalizer"}},
        {
          "name":"feature_2",
          "norm":{"class":"org.apache.solr.ltr.norm.IdentityNormalizer"}},
....
      },
      {
      "name":"model_2",
      "class":"org.apache.solr.ltr.model.MultipleAdditiveTreesModel",
      "store":"first_store",
      "features":[{
          "name":"feature_1",
          "norm":{"class":"org.apache.solr.ltr.norm.IdentityNormalizer"}},
        {
          "name":"feature_3",
          "norm":{"class":"org.apache.solr.ltr.norm.IdentityNormalizer"}},
....

Here “name” is the name of the model in the model-store. It will be visible, after the upload, in the model-store list.

Upload

To upload a model to a model-store of a specific collection, we use the curl command:

curl -XPUT "https://localhost:8983/solr/collection1/schema/model-store" --data-binary "@solr-model.json" -H "Content-type:application/json"

Where solr-model.json is the file containing the model we want to upload.

For example:

{
    "store": "first_store",
    "name": "model_1",
    "class": "org.apache.solr.ltr.model.MultipleAdditiveTreesModel",
    "features": [
        {
            "name": "feature_1"
        },
        {
            "name": "feature_2"
        },
        {
            "name": "feature_3"
        },
....

Delete

To delete a model called model_1 from the collection1 collection:

curl -XDELETE "https://localhost:8983/solr/collection1/schema/model-store/model_1"

Reload

To reload the collection1 collection:

https://localhost:8983/solr/admin/collections?action=RELOAD&name=collection1&wt=xml

Warning

In using these methods we can run into some errors.

Don’t lose the next post to be sure to correctly use every method!

// STAY ALWAYS UP TO DATE

Subscribe to our newsletter

Did you like this post about the Apache Solr Learning to Rank Feature and Model Stores? Don’t forget to subscribe to our Newsletter to stay always updated from the Information Retrieval world!

Author

Anna Ruggero

Anna Ruggero is a software engineer passionate about Information Retrieval and Data Mining. She loves to find new solutions to problems, suggesting and testing new ideas, especially those that concern the integration of machine learning techniques into information retrieval systems.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.