Solr – Searching:
In this tutorial, we will discuss about searching in Solr. Generally, end users search for some information. In background the related Search query will be sent as a request to the Solr request handler for processing. The request handler will call the standard query parser which will parse the search query and generate the search response.
Below are the common Query Parameters that will help you understand the way you can search.
There are different types of Query Parsers like Standard Query Parser, DisMax Query Parser etc. So this defType parameter can be set to select which type of query parser to use for processing. If you don’t specify anything, then by default standard query parser is used.
Sort parameter can be used to sort the search results in ascending or descending orders. You can do this for either alphabetical content or numerical content.
Start parameter holds the value to offset from where you want to display the query results. By default the value is zero. For example, if you give the value for the start parameter as 5, then the Solr will skip the first resulted 5 records and list the documents.
Rows parameter is used when you want to set the number of documents to be returned at a time for the given query. By default, its value is 10. If you set it for 20, Solr will give you 20 documents from the complete result set at one time. It’s all about the pagination.
fq (Filter Query) Parameter:
fq parameter in Solr is used to filter the data. In simple, it’s a condition based retrieval of documents from Solr. Generally any query with fq will be cached independently, next time the same kind of filter query call will hit the cache and the results will be returned very quickly.
fl (Field List) Parameter:
fl parameter is used to limit the number of fields of a document in the query response. If you mention required fields separated by comma or space in the query, it will return only those specified fields as the response.