SearchResource Resource

Search

A resource for querying of the collections.

GET /search

Simple search query. Supports pagination.

The query string is expected to be a valid Elastic Search query string.

Request Parameters
name type description default constraints
defaultoperator query the default boolean operator to use on terms in the search query (optional) OR  
fields query comma-separated list of fields to include in each result record (optional).

To exclude a field, prepend a minus to a field name; use no prefix to include it.

  • include title and date modified: title,_meta.modified
  • exclude title: -title
If this parameter is not set, all known fields are included.
   
from query the first result to include (optional)   int
limit query alias of size (optional) -1 int
offset query alias of from (optional) 0 int
q query search query to run *  
size query the number of results to return, -1 for default page size (optional)   int
sort query the field and order to sort on (optional).

To sort in descending order, prepend a minus to the field name. Examples:

  • sort on title ascending: title
  • sort on creation date descending: -_meta.created
If this parameter is not set, results are sorted by descending relevance score.
   
Response Codes
code condition
400 The search query is syntactically incorrect.
422 The pagination size limit is exceeded.
Response Body
media type data type description
application/json;profiles=tepapa.collections.api.v1 object

Example

Request
GET /search
Content-Type: */*
Accept: application/json;profiles=tepapa.collections.api.v1

                
...
                
              
Response
HTTP/1.1 200 OK
Content-Type: application/json;profiles=tepapa.collections.api.v1

                
...
                
              

POST /search

Advanced search query. Supports pagination.

The query string is expected to be a valid Elastic Search query string.

Request Body
media type data type
application/json ApiSearchRequest (JSON)
Response Codes
code condition
200 The search query was executed successfully.
400 The search query is syntactically incorrect.
422 The pagination size limit is exceeded.
Response Body
media type data type description
application/json;profiles=tepapa.collections.api.v1 object ApiSearchResult

Example

Request
POST /search
Content-Type: application/json
Accept: application/json;profiles=tepapa.collections.api.v1

                
{
  "query" : "James Cook",
  "defaultOperator" : "AND",
  "from" : 25,
  "size" : 10,
  "fields" : [ {
    "include" : true,
    "field" : "title",
    "exclude" : true
  }, {
    "include" : true,
    "field" : "_meta.*",
    "exclude" : false
  } ],
  "facets" : [ {
    "field" : "birthPlace",
    "size" : 3
  }, {
    "field" : "birthDate",
    "size" : 5
  } ],
  "filters" : [ {
    "field" : "birthPlace",
    "keyword" : "London"
  }, {
    "field" : "birthDate",
    "keyword" : "1987"
  } ],
  "sort" : [ {
    "field" : "title",
    "order" : "asc"
  }, {
    "field" : "_meta.modified",
    "order" : "desc"
  } ]
}
                
              
Response
HTTP/1.1 200 OK
Content-Type: application/json;profiles=tepapa.collections.api.v1

                
...
                
              
See Also
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html

POST /search/_scroll

Start a scroll for bulk data retrieval. The resulting temporary resource will be available for up to the given amount of time.

A scroll request is very similar to a search request, but instead of allowing to specify pagination, a Location and Link header is returned with the unique, temporary URI to the next page.

See Also
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html
Request Parameters
name type description default constraints
defaultoperator query the default boolean operator to use on terms in the search query (optional) OR  
duration query the duration this scroll should be available for in minutes 1 required
fields query list of fields to include in each result record (optional)    
q query search query to run (optional) *  
size query the size of each individual scroll response (optional) 1000 required
Response Codes
code condition
303 The scroll was initiated. See Location or Link header for the next temporary scroll location.
400 The search query is syntactically incorrect.
422 The scroll duration limit is exceeded.
Response Body
media type data type description
application/json;profiles=tepapa.collections.api.v1 object

Example

Request
POST /search/_scroll
Content-Type: */*
Accept: application/json;profiles=tepapa.collections.api.v1

                
...
                
              
Response
HTTP/1.1 303 See Other
Content-Type: application/json;profiles=tepapa.collections.api.v1

                
...