Search API search fields
editSearch API search fields
editLearn more about Weights within the Relevance Tuning guide.
The search_fields
parameter restricts a query to search only specific fields.
Restricting fields will result in faster queries, especially for schemas with many text fields.
Only available within text fields.
-
query
(required) - A string or number used to find related documents. See here for more details.
-
search_fields
(required) - Send in a search_fields object with your query.
-
fields
(optional) - Fields must exist within your Engine schema and be of type text.
-
weight
(optional) - Weight is given between 10 (most relevant) to 1 (least relevant).
Example - Specifying search_fields
for a given query.
curl -X POST '<ENTERPRISE_SEARCH_BASE_URL>/api/as/v1/engines/national-parks-demo/search' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer search-soaewu2ye6uc45dr8mcd54v8' \ -d '{ "search_fields": { "title": {}, "description": {}, "states": {} }, "query": "everglade" }'
Search Fields with Weight
editApply Weights to each search field.
Engine level Weight settings will be applied is none are provided.
Query time Weights take precedence over Engine level values.
Example - Specifying weights to favor the park title
, followed by its description
, and then their states
.
curl -X GET '<ENTERPRISE_SEARCH_BASE_URL>/api/as/v1/engines/national-parks-demo/search' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer search-soaewu2ye6uc45dr8mcd54v8' \ -d '{ "search_fields": { "title": { "weight": 10 }, "description": { "weight": 5 }, "states": { "weight": 3 } }, "query": "everglade" }'
Errors
edit
|
If a requested search field does not exist in the current schema. If a search field JSON object is malformed. It must be an empty JSON object or a JSON object with a |