This is a small bit of information on how to query Solr.
This can be used to find information in Solr.
For example, we want to find duplicates.
Two ways to query Solr:
1) Solr dashboard
Use the Solr dashboard and enter the query parameters.
2) URL string query
Paste the query URL in a browser.
The following is an example of a Solr query:
Let’s break it up:
Each part of the string represents a query filter or output configuration.
- Solr server hostname and query URL.
- fl = Field list – What columns to show in the result list.
- Rows – Number of rows to show. If left empty, 10 rows will be shown.
- Indent – Will there be indents in the output (relevant for xml output).
- Sort – according to which column do we want to sort + ascending or descending order.
- q = Query – Main query string. This is mandatory.
- wt = Wright type – How we want the results to output. In the above example we output to CSV.
- fq = Filter query – (not found in the above query string) This filters the results that came back from the main query string. Not mandatory.
- & = Used to connect between the different fields.
- AND / OR = Used in queries as regular and/or operators.
The above information is relevant for the dashboard and string queries.
Note: Browsers translate the space character to HTML format, it will be shown as %20.
It’s possible to give an alias to a column like so:
You can see that the column names uuid_s, metadata_machine_s, and keepalive_timestamp_dt are presented as Morphisec_UUID, Machine_Name, Last_Keepalive.
Not mandatory but looks nice.