Search
Search for documents matching a specific query in the given index.
This route should only be used when no API key is required. If an API key is required, use the POST route instead.
Path parameters
-
indexUid string Required
Index Unique Identifier
Query parameters
-
q string
Query string.
Default value is
""
. -
attributesToRetrieve string
Comma-separated list of attributes whose fields will be present in the returned documents. Defaults to the displayedAttributes list which contains by default all attributes found in the documents.
Default value is
*
. -
attributesToHighlight string
Comma-separated list of attributes whose values will contain highlighted matching terms. Highlighted attributes are returned in
_formatted
response object. -
highlightPreTag string
Specify the tag to put before the highlighted query terms.
Default value is
<em>
. -
highlightPostTag string
Specify the tag to put after the highlighted query terms.
Default value is
</em>
. -
attributesToCrop string
Comma-separated list of attributes whose values have to be cropped. Cropped attributes are returned in
_formatted
response object. -
cropMarker string
Sets the crop marker to apply before and/or after cropped part selected within an attribute defined in
attributesToCrop
parameter.Default value is
…
. -
cropLength integer
Sets the total number of words to keep around the matched part of an attribute specified in the
attributesToCrop
parameter.Default value is
10
. -
facets string
Comma-separated list of attributes whose fields will be distributed as a facet. If you have set up filterableAttributes, you can retrieve the count of matching terms for each facets.Learn more about facet distribution in the dedicated guide
-
Attribute(s) to filter on.
Can be made of 3 syntaxes
- Nested Array:
["something > 1", "genres=comedy", ["genres=horror", "title=batman"]]
- String:
something > 1 AND genres=comedy AND (genres=horror OR title=batman)
- Mixed:
["something > 1 AND genres=comedy", "genres=horror OR title=batman"]
_geoRadius({lat}, {lng}, {distance_in_meters}) and _geoBoundingBox([{lat, lng}], [{lat}, {lng}]) built-in filter rules can be used to filter documents within geo shapes.
Attribute(s) used in
filter
should be declared as filterable attributes. See Filtering and Faceted Search. - Nested Array:
-
offset number
Number of results to skip.
Default value is
0
. -
sort string
Fields on which you want to sort the results.
Attribute(s) used in
sort
should be declared as sortable attributes. See Sorting._geoPoint({lat}, {long}) built-in sort rule can be used to sort documents around a geo point.
-
limit number
Maximum number of results to return.
Default value is
20
. -
page number
Sets the specific results page.
Default value is
1
. -
hitsPerPage number
Sets the number of results returned for a query. If hitsPerPage is not provided as a query parameter, this parameter is ignored.
Default value is
20
. -
showMatchesPosition boolean
Defines whether an
_matchesPosition
object that contains information about the matches should be returned or not.Default value is
false
. -
matchingStrategy string
Defines which strategy to use to match the query terms within the documents as search results. Two different strategies are available,
last
andall
. By default, thelast
strategy is chosen.Values are
last
orall
. Default value islast
.
curl \
-X GET https://example.meilisearch.com:7700/indexes/movies/search \
-H "Authorization: Bearer $ACCESS_TOKEN"
{
"hits": [
{
"id": 25684,
"title": "American Ninja 5",
"poster": "https://image.tmdb.org/t/p/w1280/iuAQVI4mvjI83wnirpD8GVNRVuY.jpg",
"overview": "When a scientists daughter is kidnapped, American Ninja, attempts to find her, but this time he teams up with a youngster he has trained in the ways of the ninja.",
"release_date": 725846400,
"_formatted": {
"id": 25684,
"title": "American Ninja 5",
"poster": "https://image.tmdb.org/t/p/w1280/iuAQVI4mvjI83wnirpD8GVNRVuY.jpg",
"overview": "When a scientists daughter is kidnapped, American <em>Ninja</em>, attempts to find her, but this time he teams up with a youngster he has trained in the ways of the <em>ninja</em>.",
"release_date": 725846400
},
"_matchesPosition": {
"overview": [
{
"start": 49,
"length": 5
},
{
"start": 155,
"length": 5
}
]
}
}
],
"facetDistribution": {
"genres": {
"action": 273,
"animation": 118,
"adventure": 132,
"fantasy": 67,
"comedy": 475,
"mystery": 70,
"thriller": 217
}
},
"facetStats": {
"price": {
"min": 1,
"max": 4999.99
}
},
"limit": 0,
"offset": 0,
"estimatedTotalHits": 0,
"query": "string",
"processingTimeMs": 0
}
{
"message": "The Authorization header is missing. It must use the bearer authorization method.",
"code": "missing_authorization_header",
"type": "auth",
"link": "https://docs.meilisearch.com/errors#missing_authorization_header"
}