Search

How to Use Apache Solr Request Parameters API

Hi readers,
If you too got lost in the Solr documentation looking for how to use the request parameters API [1], this is the tip and trick for you!

Here we are going to show you how to change the default query type (qt) parameter of the implicit /admin/ping request handler [2]. This handler has a default set of parameters (paramset) called _ADMIN_PING which we are going to change.

In our solrconfig.xml we decided to remove the /select endpoint and only rely on the /query one. The /select endpoint, however, is the one used by default by the /admin/ping handler; removing it makes the handler not work anymore.

Here is the request to view the paramset of the /admin/ping handler:

				
					http://localhost:8983/solr/books/config/requestHandler?componentName=/admin/ping&expandParams=true
				
			

And the result:

				
					{
  "responseHeader": {
  "status": 0,
  "QTime": 1
  },
  "config": {
    "requestHandler": {
      "/admin/ping": {
        "class": "solr.PingRequestHandler",
        "useParams": "_ADMIN_PING",
        "invariants": {
          "echoParams": "all",
          "q": "{!lucene}*:*"
        },
        "name": "/admin/ping",
        "_useParamsExpanded_": {
          "_ADMIN_PING": "[NOT AVAILABLE]"
        },
        "_effectiveParams_": {
          "q": "{!lucene}*:*",
          "echoParams": "all"
        }
      }
    }
  }
}
				
			

If no qt is defined, Solr is using the default one which is the /select.

Here is the curl request to change the query type (qt) parameter from /select to /query.

				
					curl http://localhost:8983/solr/books/config/params -H 'Content-type:application/json'  -d '{
  "set": {
    "_ADMIN_PING": {
      "qt": "/query"
    }
  }
}'
				
			

To check that the parameter has been set correctly:

				
					http://localhost:8983/solr/books/config/requestHandler?componentName=/admin/ping&expandParams=true
				
			

And the result:

				
					{
  "responseHeader": {
    "status": 0,
    "QTime": 1
  },
  "config": {
    "requestHandler": {
      "/admin/ping": {
        "class": "solr.PingRequestHandler",
        "useParams": "_ADMIN_PING",
        "invariants": {
          "echoParams": "all",
          "q": "{!lucene}*:*"
        },
        "name": "/admin/ping",
        "_useParamsExpanded_": {
          "_ADMIN_PING": {
            "qt": "/query",
            "": {
              "v": 0
            }
          }
        },
        "_effectiveParams_": {
          "q": "{!lucene}*:*",
          "qt": "/query",
          "echoParams": "all"
        }
      }
    }
  }
}
				
			

Hope this helps you!

Need Help With This Topic?​​

If you’re struggling with request parameters API, don’t worry – we’re here to help! Our team offers expert services and training to help you optimize your Solr search engine and get the most out of your system. Contact us today to learn more!

Need Help with this topic?​

If you're struggling with request parameters API, don't worry - we're here to help! Our team offers expert services and training to help you optimize your Solr search engine and get the most out of your system. Contact us today to learn more!

Other posts you may find useful

Sign up for our Newsletter

Did you like this post? Don’t forget to subscribe to our Newsletter to stay always updated in the Information Retrieval world!

Leave a Reply

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.