Product Selector

Fusion 5.9
    Fusion 5.9

    Solr Query Language Cheat Sheet

    This cheat sheet is a quick reference to the Solr query language. Use this syntax when querying Fusion via the Query Profiles API.

    Additional information about Solr query syntax can be found in the Solr Query documentation.

    There are two ways to query a Fusion collection using the parameters below:

    Wildcards

    Wildcards and regular expressions are supported.

    • ?

      Single-character wildcard

    • *

      Multi-character wildcard

    Escape characters

    Some characters in query fields must be escaped using a backslash \. Adding \ before the following includes them in the query as literal values:

    • ?

    • *

    • \

    • /

    • "

    Queries against facets are case sensitive.

    Common query parameters

    q

    Defines a query using standard query syntax. This parameter is mandatory.

    fq

    Filter query. A query string that limits the query results without influencing their scores.

    sort

    Sort field/direction. The field on which to sort, followed by a space and direction (desc or asc). You can specify multiple sort fields like this: sort=title asc,year desc.

    rows

    Max results per page. This sets the "page size" for paginated search results.

    start

    Pagination offset. The number of results to skip, for pagination purposes.

    fl

    Field List. The list of fields to return in the query results.

    df

    Default field. Used to configure the q and fq parameters. If not specified, the default field is text.

    wt

    Response writer. Select the response format by specifying one of Solr’s response writers.

    Query examples

    1. Search only the title field in the "docs" collection for the term "solr", and format the results as JSON:

    http://FUSION_HOST:FUSION_PORT/api/query-pipelines/default/collections/docs/select?q=solr&fl=title&wt=json
    1. Use the following query with wildcards and character escaping in the Query Workbench to search for both BLU RAY MOVIES and CAMERA classes in the VIDEO/CD and PHOTO/CAMERA departments:

      • class_s:*RA* AND department_s:*O\/C*

    1. Use a movie collection to select the movie ID and rating where the rating is equal to 4.

    http://FUSION_HOST:FUSION_PORT/api/query-pipelines/default/collections/docs/select?q=*:*&fl=movie_id,rating&fq=rating:4
    1. Search for movies with "black" in the title, starting at the 20th result for pagination, then return the results as XML:

    http://FUSION_HOST:FUSION_PORT/api/query-pipelines/default/collections/docs/select?q=black&fl=title&start=20&rows=20&wt=xml

    Additional resources

    Lucidworks offers free training to help you get started with Fusion. Check out the Advanced Query Tools course, which focuses on advanced query language techniques, such as using query parameters, function queries, nested queries, and different query parsers:

    Advanced Query Tools

    Visit the LucidAcademy to see the full training catalog.