Unicat API Reference

Up - API Reference - Home


/api/p/<project gid>/records/search

Requires JWT.

Search for records.

Request

POST /api/p/<project gid>/records/search
Authorization: Bearer <JWT>

{
    "language": "nl",
    "q": "+cms +225",
    "filter": ["classes", "has", "article"]
}

language is the language to search in

optional

q is the query to perform
filter assets must match this filter
page.top (default 0) only return records starting from the top-index (0-based).
page.size (default 10) only return this many records.

You must provide at least one of q and filter, otherwise you'll get an empty result.

q

A set of terms to search for; they will determine the relevancy score. If you prefix a term with a + it must be present in the record, if you prefix it with a - is must not be present.

filter

We use a filter to narrow down the results, based on field values, validation checks, and other properties. A filter supports boolean logic (AND, OR, NOT) and nesting. Read the basic workings of a filter to learn how to build complex (or simple) filters.

Shared filter properties

updated_on < | > | between [value, "days"] or [value_from, value_until]

< match records that were updated fewer than <value> days ago
> match records that were updated more than <value> days ago
between match records that were updated in the <value_from> - <value_until> period.

We only support "days" for now, for the < and > operators. For the between operator we need the value_from and value_until in UNIX timestamp value (seconds since 1970).

validation any | is_empty | not_translated

any any validation failed
is_empty validation returned an empty value
not_translated validation of a localized text returned an empty value for the current language, but the same field does have a value in at least one other language

Note: an empty field is not seen as a validation failure (and isn't included in results for 'any')

Specifically for records, we have additional operators to check field validations; see below.

Record-specific filter properties

definition is | is_exactly | like value

is match records that have this definition or extended definitions based on it
is_exactly match records that have this exact definition
like match records that share the same base definition

Specify the value by gid or name.

classes has value

has match records that have this class

Specify the value by gid or name.

fields has value

has match records that have this field (through definition or through class)

Specify the value by gid or name.

value <operator> [field, value]

<operator> the available operators depend on the field's type

Specify the field by gid or name. The value depends on the field's type.

validation any | is_empty | not_translated | invalid_input | is_required | min | max | decimals | min_items | max_items | min_length | max_length | restrict_to_values optional_field

The optional_field can be empty to check if there are any (specific) validation failures for this record. To check a specific field, provide its gid or name. Some of the operators depend on the type of field, like min/max for numeric fields.

any any validation failed
is_empty validation returned an empty value
not_translated validation of a localized text returned an empty value for the current language
invalid_input invalid input for type (and optional format)
is_required field is empty but required
min value is below the minimum (number and decimal fields)
max value is above the maximum (number and decimal fields)
decimals value doesn't have the exact number of specified decimal places (decimal fields)
min_items value has fewer than the minimum number of items (list fields)
max_items value has more than the maximum number of items (list fields)
min_length value has a length below the minimum (text fields)
max_length value has a length above the maximum (text fields)
restrict_to_values value is not in the specified list

channels has | has_not value

has match records included in this channel
has_not match records not in this channel

The value is the channel's key.

childdefinitions mixed_children | foreign_children | expected_children

mixed_children match records whose children don't all have the exact same definition (even if that is allowed)
foreign_children match records where some children have a definition that is not in the childdefinitions list (always true if that list is empty and children exist)
expected_children match records that have a childddefinitions list but are without children

There is no value.

is_link is_true | is_false

Linked records point back to an original.

is_deleted is_true | is_false

Deleted records can be undeleted.

Success response

Authorization: <JWT>

{
    "success": true,
    "result": {
        "records": ["96ec02b2-fb8d-4fb4-b952-fad0c4b88a74", ],
        "records.size": 17
    },
    "data": {
        "records": {
            "96ec02b2-fb8d-4fb4-b952-fad0c4b88a74": {
                
            },
            
        }
    }
}

result

records paginated results for the query, in relevancy order
records.size the size of the non-paginated results for the query

data

records Record info with hierarchy, definition, field values.

Error responses

400 Bad request - missing parameters or wrong type or value
401 Unauthorized - missing or expired JWT
403 Forbidden - not a member of this project
422 Unprocessable entity - can't match records with search engine results
1002 Search error - internal search engine error

HTTP/1.1 422 Unprocessable entity

{
    "success": false,
    "result": {
        "code": 1002,
        "message": "Search error",
        "info": {}
    },
    "data": {}
}