Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

range (Structured Query)

isubiker edited this page Nov 11, 2011 · 1 revision

Range queries use the ranges as created using the manage range service. Ranges allow for the efficient fetching of documents by key/value using an operator other than equality. For example, to select documents that had a price less than 14.99, a range query is what would be used:

{
    "range": "price", // The name references the name of the range as specified when creating
    "value": 14.99   // Can be a boolean, number, string or an array of numbers or strings
}

<constraint>
    <range>price</range>
    <value type="number">14.99</value>
</constraint>

If an array of values is given, the constructor will match documents that contain any of the values in the array.

Let's say we're looking for documents that have a price between 10 and 14.99. This query can easily be constructed as:

{
    "range": "price",
    "from": 10.00,
    "to": 14.99
}

<constraint>
    <range>price</range>
    <from type="number">10.00</from>
    <to type="number">14.99</to>
</constraint>

If the range being used is actually a bucketed range, the label from the bucket can be used in place of the "value" key:

{
    "range": "price", // The name references the name of the range as specified when creating
    "bucketLabel": "Less than $5"
}

<constraint>
    <range>price</range>
    <bucketLabel>Less than $5</bucketLabel>
</constraint>

Optional configuration:

  • operator (string) - Must be one of lt, le, gt, ge, eq or ne.
  • minimumOccurances (number) - Specifies the minimum number of occurrences required. If fewer that this number of words occur, the document does not match. The default is 1.
  • maximumOccurances (number) - Specifies the maximum number of occurrences required. If more than this number of words occur, the document does not match. The default is unbounded.
Clone this wiki locally