Query Syntax#

Profiles: Project Creator, Search User

You can use query syntax within Squirro search bars to return better, more refined search results.

This page details the query syntax techniques available within Squirro.

Project creators can configure query syntax options. Search users can use the techniques outlined in this page to improve search accuracy.

Download the Advanced Query Syntax Cheat Sheet PDF for a handy reference.

Introduction#

Per default, the title and body fields are taken into account when searching.

Sequences of query terms are combined using the OR operator, although the project’s configured minimum-should-match strategy also applies.

Dynamically tagged text labels can also be configured to be searchable.

Reference: For details, see How To Use Best-Bets Labels to Map Query Terms.

Boolean Operators#

Use AND, OR, NOT, + (plus sign) or - (minus sign) to explicitly combine terms. Be aware that the operators need to be in all capital letters.

The following restrictions apply:

  • The + or required operator requires that the term after the + symbol exists somewhere.

  • The - or prohibit operator excludes documents that contain the term after the - symbol.

Example Boolean Queries#

Query

Description

squirro AND memonic

Search documents that contain squirro and memonic.

squirro OR memonic

Search documents that contain either squirro or memonic.

+memonic -squirro

Search documents that contain memonic but do not contain squirro.

squirro NOT memonic

Search documents that contain squirro but do not contain memonic.

Grouping#

Use round brackets / parentheses for grouping.

Example Grouping Queries#

Query

Description

(java AND solr) OR (python AND elasticsearch)

Search documents that contain both java and solar, or documents that contain both python and elasticsearch.

nektoon AND (squirro OR memonic)

Search documents that contain nektoon and either squirro or memonic.

Boosting#

Individual elements of a query can be prioritized by boosting them. Note that sorting needs to be by relevance to notice the changed relevance scores.

Example Boosted Queries#

Query

Description

France^10 Europe

Search for France and Europe, but boost matches of “France”.

France OR Country:France^10

Search for France in full text, as well as the “Country” label and boost items that have the value defined in the country label.

France^0.1 Europe

Search for France and Europe, but de-prioritize matches of “France” (the default boost is 1.0).

Sorting#

You can use the following query syntax to sort the result:

sort:<field_name>[:<order>]

Where <field_name> is either date (default) or relevance or any item field name you want to sort by and <order> is either asc for ascending or desc for descending. The order suffix is optional, the default order is descending.2

Additionally, you can add a second (or third etc) sorting criteria by adding

[;<2nd_sort_field>[:<2nd_order>]]

to the query syntax.

2 Note: The square brackets above mean that those fields are optional. Those brackets are not part of the syntax.

Example Sorting Queries#

Query

Description

sort:date

Sort by date (descending order by default)

sort:date:asc

Sort by date in ascending order

sort:relevance:desc

Sort by relevance in descending order

sort:my_sortable_facet:desc;date:desc

Sort by “my_sortable_facet” in descending order; additionally add a second sorting by descending date

(Moon landing) sort:date

Sort query by date (default order is descending)

Time Increment#

It is possible to control the time increments shown in the main timeline and in the dashboard widgets. To do so, add time_increment:<value> to a query.

Here is the Bugzilla Project without a time_increment set:

image1

The same query, with time_increment:year

image2

Possible values are:

time_increment:minute
time_increment:hour
time_increment:day
time_increment:week
time_increment:month
time_increment:quarter
time_increment:year

This can also be combined with values for more flexibility. For example:

time_increment:12hours
time_increment:4days
time_increment:8weeks
time_increment:6months
time_increment:3year

There is a performance impact when using a time increment that results in many individual increments. This impact is both in the user interface, where each increment needs to be drawn, as well as on the Elasticsearch level, where they need to be calculated. So use the time_increment setting carefully.

Starred and Read Items#

Starred items are items marked as favorite / bookmarked items.

Note: You need to enable flags for your project(s) before you can query for starred and read items. To do so, set the enable_flags_for_project_ids property in topic.ini. For more details, see topic.ini.

Query syntax for (un)starred items and (un)read items:

is:starred
is:unstarred
is:read
is:unread

Cheat Sheet#

Download the Advanced Query Syntax Cheat Sheet PDF shown in the image below for a handy reference guide:

Image of the Advanced Query Syntax Cheat Sheet