EGF2 Search API

EGF2 uses ElasticSearch to power search functionality. Data is added to ES by sync service that is listening to the system event queue.

ES indexes dedicated for a single or multiple object types are supported. Simple object related indexes can be added via configuration. In case complex processing is necessary a custom index handler can be added to sync.

client-api provides a GET /v1/search endpoint for searching. The following parameters are supported:

  • q - textual query, optional. In case q is not specified all objects from an index will returned (paginated, of course)
  • fields - comma separated list of fields. Here you can list fields that the q query should be searched in.
  • object - object type name. This parameter identifies ES index that will be used for searching. In most cases ES index name will correspond to an object type name, e.g. “user” index for User objects. It is also possible to have a non trivial index spanning several objects / edges. Those indexes named in an arbitrary manner, preferably using object type names for clarity sake.
  • filters - comma separated key value pairs, e.g. filters=category:123,size:12. In case ! sign is added in front of a value server will return results that do not contain this value. Example filters=manufacturer:!23423435 - return only results that do not have manufacturer field with specified value.
  • sort - comma separated list of fields to be used for sorting, with optional direction specifier in parenthesis, i.e. gender(DESC)

Results are returned in paginated format, the same as results for getting edges. Full expansion functionality is supported for search requests as well, the same as for regular graph API requests.

ACL rules are applied to the search results in the same way as they are applied to the results of graph API get edge requests. Access control is enforced throughout all endpoints exposed by EGF2.

Note: EGF2 does not provide direct access to ES cluster for client applications. There are two main reasons for this:

  • security
  • as the exact details of requests made to ES are hidden from the client apps it is possible to substitute ElasticSearch with a different search engine.

Search endpoint is a powerful tool that allows virtually any data representation to be prepared and accessed in a very efficient way.

See Next - Edges Vs Search

comments powered by Disqus