API Docs

Search engine API.

class invenio_search.api.DefaultFilter(query=None, query_parser=None)[source]

Shortcut for defining default filters with query parser.

Build filter property with query parser.

query

Build lazy query if needed.

class invenio_search.api.RecordsSearch(**kwargs)[source]

Example subclass to searching records using Elastic DSL.

Use Meta to set kwargs defaults.

class Meta[source]

Configuration for Search and FacetedSearch classes.

default_filter = None

Default filter added to search body.

Example: default_filter = DefaultFilter('_access.owner:"1"').

Return faceted search instance with defaults set.

Parameters:
  • query – Elastic DSL query object (Q).
  • filters – Dictionary with selected facet values.
  • search – An instance of Search class. (default: cls()).
RecordsSearch.get_record(id_)[source]

Return a record by its identifier.

Parameters:id – The record identifier.
Returns:The record.
RecordsSearch.get_records(ids)[source]

Return records by their identifiers.

Parameters:ids – A list of record identifier.
Returns:A list of records.

Configuration

Invenio Search Engine config parameters.

Utilities

Utility functions for search engine.

invenio_search.utils.build_index_name(*parts)[source]

Build an index name from parts.

invenio_search.utils.schema_to_index(schema, index_names=None)[source]

Get index/doc_type given a schema URL.

>>> from invenio_search.utils import schema_to_index
>>> schema_to_index('records/record-v1.0.0.json')
('records-record-v1.0.0', 'record-v1.0.0')
>>> schema_to_index('default-v1.0.0.json')
('default-v1.0.0', 'default-v1.0.0')
>>> schema_to_index('default-v1.0.0.json', index_names=[])
(None, None)
>>> schema_to_index('invalidextension')
(None, None)
Parameters:
  • schema – The schema name
  • index_names – A list of index name.
Returns:

A tuple containing (index, doc_type).