Skip to main content

Search Parameters

Here is the list of parameters that you can send when using the search endpoints.

query

string

The text to search in the index.

If the text is empty or absent, the search will match every object in your index.

{
"query": "covid"
}

Pagination

page

integer default: 0

Page number of the results to fetch. When a page higher than the total number of pages is specified, an empty hits array is returned.

{
"page": 1 // will return hits of page 1
}

perPage

integer default: 20

Results per page (max 250)

{
"perPage": 5 // will return 5 hits per page
}

Properties

properties

Array<string>

Gives control over which properties to retrieve inside the records.

You may have some use cases where only a handful of properties inside the record may be needed for display purposes.

By setting this parameter, it will help optimize the response size.

{
"properties": ["property1", "property2"]
}

searchProperties

Array<string>

Gives control over which properties to search inside the records. The property needs to be searchable else it will be ignored.

You may only want to search inside the name property of a record for example.

{
"searchProperties": ["property1", "property2"]
}

Filtering

facetFilters

Array<string>

Filter hits by facet value or numeric value.

Value

Format: ${propertyName}:${value}

Numeric Comparisons

Format: ${propertyName} ${operator} ${operand}

Supported operators are <, <=, =, !=, >= and >, with the same semantics as in virtually all programming languages.

Numeric Range

Format: ${propertyName}:${lowerBound} TO ${upperBound}

Multiple filters: If you specify multiple filters, they are interpreted as a conjunction (AND). If you want to use a disjunction (OR), use a nested array.

{
"facetFilters": [
"property:value" // single value

// property1 = value AND property2 = value
"property1:value", "property2:value"

// property1 = value OR property2 = value
["property1:value", "property2:value"]

// (property3 = value OR property2 = value) AND property3 = value
["property1:value", "property2:value"], "property3:value"
]
}

Faceting

Array<string>

facets

Facets to retrieve.

Each of the specified facets, will be returned in the response as list of facet values in records matching the query and returned with its associated count (number of matched records containing the value).

Note

The property specified needs to be facetable.

{
"facets": ["services.en"]
}

Highlighting

highlightProperties

Array<string>

Gives control over which properties to highlight. The property needs to be searchable else it will be ignored.

{
"highlightProperties": ["property1", "property2"]
}

highlightPreTag

string

Use in conjunction with highlightPostTag to define the HTML tags to use for the highlighted text. By default, highlighted text is wrapped in <strong> and </strong> tags.

{
"highlightPreTag": "<em>"
}

highlightPostTag

string

Use in conjunction with highlightPreTag to define the HTML tags to use for the highlighted text. By default, highlighted text is wrapped in <strong> and </strong> tags.

{
"highlightPostTag": "</em>"
}

aroundLatLng

string

Search for entries around a central geolocation, enabling a geo search within a circular area.

{
"aroundLatLng": "lat,lng"
}

aroundRadius

integer | 'all'

Define the maximum radius for a geo search (in meters).

This parameter is only considered within the context of a radial geo search, enabled by specifing the aroundLatLng parameter.

  • If you specify the meters of the radius (instead of all), then only records that fall within the bounds of the circle will be returned.
  • If you use all, no filtering will be applied based on the radius.
  • If you do not specify this parameter, the radius is automatically computed from the density of the results.

insideBoundingBox

Array<floats>

Search inside a rectangular area (in geo coordinates).

{
"insideBoundingBox": [
[
southWestLng,
southWestLat,
northEastLng,
northEastLat,
],
[...] // it's possible to search in multiple bounding boxes
]
}

insidePolygon

Array<floats>

Search inside a polygon (in geo coordinates, in (lat,lng) format).

A polygon is made of at least 3 different coordinates and 1 repeated coordinate, so the polygon actually forms a closed area. A polygon can contain any pair number of coordinates above 8.

45.4553143, -73.9778137  // First coordinate
45.6869956, -73.5575867 // Second coordinate
45.5813675, -73.3255005 // Third coordinate
45.4553143, -73.9778137 // Repeated first coordinate

You may specify multiple polygons, to form AND and OR statements, in order to search within multiple polygons at a time.

{
"insidePolygon": [
// polygon 1
], // search for resources located within polygon 1
"insidePolygon": [
[
// polygon 1
],
[
// polygon 2
]
], // search for resources located within polygon 1 AND polygon 2.
"insidePolygon": [
[
[
// polygon 1
],
[
// polygon 2
]
]
], // search for resources located within polygon 1 OR polygon 2.
"insidePolygon": [
[
[
// polygon 1
],
[
// polygon 2
]
],
[
// polygon 3
]
] // search for resources located within (polygon 1 OR polygon 2) AND polygon 3.
}

aroundLatLng, aroundLatLngViaIP and insideBoundingBox will be ignored if used along with this parameter.


Query Strategy

queryType

string default: prefix_none

Controls if and how query words are interpreted as prefixes.

  • prefix_none: No query word is interpreted as a prefix
  • prefix_last: Only the last word is interpreted as a prefix
  • prefix_all: All the words are interpreted as a prefix
{
"queryType": "prefix_last"
}

Sorting

sort

string default: score

Tells the engine how to order the search results. Some predefined values are available.

  • score: order the hits by a combination of criterias
  • geo: order the hits by distance

Custom field ordering is also available with the following pattern <order>(<property>).

The order value can be of:

  • asc: ascending order
  • desc: descending order

The property value refers to a property path. For example to sort the hits by last updated the parameter would look like:

{
"sort": "desc(updatedAt)"
}