Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Search

Searching documents

post
Preview

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:

Type
Scope 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_read or customermanagement.legalentity_read, returns every document.

  • A restricted read scope, such as customer.customer_read--DE#AT, returns only documents whose restriction (customer) or restrictions (legal entity) contains one of the listed values. A restricted scope with no values returns 403 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.

Required scopes
This endpoint requires the following scopes:
  • : Needed to search documents, to read saved searches, and to read search indexes and index jobs.
Authorizations
OAuth2clientCredentialsRequired
Token URL:
Path parameters
tenantstring · min: 3 · max: 16Required

Your Emporix tenant's name. Note: The tenant should always be written in lowercase.

Pattern: ^[a-z][a-z0-9]+$
typestringRequired

Type of documents to search. Use a custom schema type, customer, or legal-entity.

Example: VEHICLE
Query parameters
pageNumberinteger · min: 1Optional

Page number to be retrieved. The number of the first page is 1.

Default: 1
pageSizeinteger · min: 1 · max: 2000Optional

Number of items to be retrieved per page.

Default: 60
sortstringOptional

List 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.

Example: name:ASC,id:DESC
fieldsstringOptional

Comma-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.

Example: id,name,_score
Header parameters
Accept-LanguagestringOptional

List 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.
X-Total-CountbooleanOptional

Flag indicating whether the total count of retrieved items should be returned.

Default: false
Body

A direct search or a saved search. When searchQueryId is present, the service runs the saved search and ignores the other properties.

anyOptional
or
anyOptional
or
Responses
200

The search succeeded. The body is the current page of matching documents.

application/json
post/search/{tenant}/search/{type}
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?