Search

Searches documents of one type. The search.search_read scope is required.
For a direct search, the body names an index and supplies queries, a filter, or both. A list of queries matches when any query matches. An and group matches when every query matches. An or group matches when any query matches. Filters narrow the matches. The response is a JSON array of matching documents. When fields is omitted, each document also includes _score.
When the body contains searchQueryId, the request runs a saved search. query is required. The saved search supplies the index, the filters, and the query shape. query replaces the text of every search term. A saved search that contains only filters keeps those filters.
When the X-Total-Count request header is true, the response includes the X-Total-Count header with the number of matching documents. The response body stays an array.
Filter and sort fields must be indexed. For a direct search, that is the index named by index. For a saved search, that is the index stored on the saved search.
A TEXT or PHRASE query can set analyzer to the field's analyzer or to one of its additional analyzers. When analyzer is omitted, the query uses the field's analyzer.
Additional permissions requirements:
Custom Schema Type
schema.custominstance_read, custom.{type}_read, or custom.{type}_read_own
customer
customer.customer_read or customer.customer_read_own
legal-entity
customermanagement.legalentity_read or customermanagement.legalentity_read_own
A caller without one of those scopes receives 403 Forbidden.
For customer and legal-entity, the scopes also limit which documents are returned:
The unrestricted read scope,
customer.customer_readorcustomermanagement.legalentity_read, returns every document.A restricted read scope, such as
customer.customer_read--DE#AT, returns only documents whoserestriction(customer) orrestrictions(legal entity) contains one of the listed values. A restricted scope with no values returns403 Forbidden.The own-read scope returns only the caller's own customer or the caller's own legal entity. When the access token does not identify that customer or legal entity, the request returns
403 Forbidden.
When a caller has both a restricted scope and the own-read scope, a document must match both.
- : Needed to search documents, to read saved searches, and to read search indexes and index jobs.
Your Emporix tenant's name. Note: The tenant should always be written in lowercase.
^[a-z][a-z0-9]+$Type of documents to search. Use a custom schema type, customer, or legal-entity.
VEHICLEPage number to be retrieved. The number of the first page is 1.
1Number of items to be retrieved per page.
60List of properties used to sort the results, separated by commas. The order of properties indicates their priority in sorting.
Possible values:
{fieldName}{fieldName}:ASC{fieldName}:DESC
When the direction is omitted, the field is sorted in ascending order.
For the localized name field, the language can be included as name.{language}. When the language is omitted, the service uses the language from Accept-Language.
When sort is omitted, results are ordered by search relevance.
name:ASC,id:DESCComma-separated list of fields to return. When the parameter is omitted, the stored document is returned.
id selects the document identifier. _score selects the relevance score.
id,name,_scoreList of language codes acceptable for the response.
- If the header is set to a language or a list of languages, the service returns the first requested language that has a translation. Localized fields are maps with that language code as the key.
- If the header is set to
*, localized fields are retrieved as maps of translations, where the keys are language codes and values are the fields in their respective languages. - If the header is empty, localized fields are retrieved as maps containing a single translation, where the key is a language code and the value is the field in the specified language. The endpoint assumes that localized fields are to be retrieved in the tenant's default language defined in the Configuration Service.
- If none of the requested languages has a translation, the localized fields are omitted from the response.
Flag indicating whether the total count of retrieved items should be returned.
falseA direct search or a saved search. When searchQueryId is present, the service runs the saved search and ignores the other properties.
The search succeeded. The body is the current page of matching documents.
The request is invalid, or a filter or sort field is not indexed.
The authorization token is invalid or has expired.
The access token does not include the required search.search_read scope, or a scope required to read the documents.
No saved search with this id exists for the tenant and type. Returned when the body contains searchQueryId.
A server-side error occurred.
For a type other than customer or legal-entity, the Schema Service could not confirm that the type is a custom entity.
POST /search/{tenant}/search/{type} HTTP/1.1
Host: api.emporix.io
Authorization: Bearer YOUR_OAUTH2_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 159
{
"index": "custom-entities",
"queries": [
{
"type": "TEXT",
"query": "diesel engine",
"field": "name.en"
}
],
"filters": {
"field": "status",
"operator": "EQ",
"value": "ACTIVE"
}
}[
{
"id": "64f1c2a8e4b0a1d2c3e4f5a6",
"name": {
"en": "Diesel engine"
},
"status": "ACTIVE",
"horsepower": 180,
"_score": 4.2
},
{
"id": "64f1c2a8e4b0a1d2c3e4f5b7",
"name": {
"en": "Diesel generator"
},
"status": "ACTIVE",
"horsepower": 220,
"_score": 3.1
}
]Last updated
Was this helpful?

