Skip to content

String Query Syntax

isubiker edited this page Oct 25, 2011 · 2 revisions

String Query Syntax

Query strings can be used in a variety of areas in Corona. Not only can they be used to search for documents, they can be used to select documents to delete and generate facets. The syntax for the string queries is intended to cover the common search box needs of a website or application. The goal is to make it easy to take the string queries as supplied by the user and directly hand it to Corona, getting results back in return.

Supported Syntax

Simple keywords

Example: Coen brothers movies

With simple keywords, documents will match the query as long as all of the keywords in the query are also present in the document. This means that without any modifications all the terms are and'd together. These search terms are also stemmed so a search for "movies" will also match documents that contain the term "movie" (note the singular form).

Without configuring any anonymous places, a document will match if the search terms are found anywhere in the document. If any content items are configured, a document will match only if the terms are found somewhere inside any of the configured content items.

Quoted strings

Example: "Donny, you're out of your element"

Quoted strings are treated exactly like simple keywords, except that the document will match only if it contains the quoted string.

Fielded searches

Example: title:Lebowski dream sequence

  • A range called "cheaper-than" that uses the price key which is a number and the less than (lt) operator
  • A place called "director" which includes the director key and is in the textContains mode

Fielded queries allow the user to explicitly state where a search term should be found in order for a document to match. They follow the common <field-name>:<value> pattern that many search engines today use. The field name can be a bucketed range, a range, or a place. If a field name is specified and no field with that name exists, it is treated as a simple search term.

To help explain fielded searches, let's assume that the following has been configured:

  • A place called "title" that is comprised of both movieTitle and subTitle keys

title:Lebowski dream sequence

The above query will find documents where "Lebowski" is found in the title field and the terms "dream" and "sequence" are found in the anonymous places, if any are configured, or anywhere in the body of the document otherwise.

Grouping with parentheses

Example: (title:Lebowski OR title:Country OR title:Fargo) AND (cast:Buscemi OR cast:Jones)

Grouping can be used when it's required to express complex combinations of terms. The above query will match documents that have Lebowski, Country or Fargo in their titles and also have Buschemi or Jones in their cast.

Negation

Example: director:Coen -director:Ethan

To exclude documents that match a term, the hyphen (-) is prepended in front of the term. The above example will search for documents that have "Coen" as the director but not "Ethan".

Or'd terms

Example: director:"Joel Coen" OR director:"Ethan Coen"

By default terms are and'd together. To have terms or'd together, use the OR modifier.

Proximity

Example: peed NEAR rug

To ensure that documents should match only if the terms are close to each other, use the NEAR modifier:

peed NEAR rug NEAR bill

This will ensure that the words peed, rug and bill are found no further than 10 words from each other. To control the distance between the terms use the NEAR/<n> modifier:

peed NEAR/5 rug NEAR/5 bill

This query will ensure that the terms are no more than 5 words apart in matching documents.

Discussion

This page should probably discuss date matching.

How should I search for "chat" in French vs English?

Clone this wiki locally