University of Gothenburg Searching API
Searching is the main way to get data from Karp. If a query string is given, an actual search will be done, otherwise all entries in the resource will be returned. - Use [`/query`](#tag/Searching/operation/query_query__resources__get) to be given all the matching entries - Use [`/query/stats`](#tag/Searching/operation/query_stats_query_stats__resources__get) to only be given the count of matches in each given resource ### Query language #### Search strings In the examples below, `` can be either: - any characters except `"`, `|`, `(` or `)` - any characters, enclosed in double quotes, but any `"` inside the quotes must be escaped with `\`, for example: `equals|field|"A "good" example"` In addition to these rules, characters that are part of the URI syntax, such as `?` and `&` needs to be encoded. For example, the whole query can be encoded using Javascript's `encodeURIComponent`. #### Query operators - `contains||` Find all entries where the field contains . More premissive than equals. - `endswith||` Find all entries where the field ends with - `equals||` Find all entries where equals . Stricter than contains - `exists|` Find all entries that has the field . - `freetext|` Search in all fields for and similar values. - `gt||` Find all entries where is greater than . - `gte||` Find all entries where is greater than or equals . - `lt||` Find all entries where is less than . - `lte||` Find all entries where is less than or equals . - `missing|` Search for all entries that doesn't have the field . - `regexp||` Find all entries where the field matches the regex . - `startswith||` Find all entries where starts with . #### Logical Operators The logical operators can be used both at top-level and lower-levels. - `not(||||...)` Find all entries that doesn't match the expression . - `and(||||...)` Find all entries that matches AND . - `or(||||...)` Find all entries that matches OR . #### Sub-queries - searching in collections of objects Used for fields with setting `collection: true` and that contain other fields (collection of objects). Boolean queries such as: `and(equals|my_field.x|1||equals|my_field.y|3)` will find entries where objects in `my_field` match `equals|x|1` or `equals|y|3`, or both. To find entries where an individual object in `my_field` matches a boolean query, wrap the query with the sub-query notation: `my_field(and(equals|x|1||equals|y|3))`. - `(expression)` Do `` on objects inside ``. `` must be a collection. #### Regular expressions Always matches complete tokens. #### Examples - `not(missing|pos)` - `and(freergxp|str.*ng||regexp|pos|str.*ng)` - `and(missing|pos||equals|wf||or|blomma|äpple` - `and(equals|wf|sitta||not||equals|wf|satt`