Skip to content

Commit

Permalink
docs: fix doctest for default index config
Browse files Browse the repository at this point in the history
  • Loading branch information
slint committed Oct 18, 2024
1 parent 6a6515e commit 8985dd0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions invenio_indexer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,19 @@
Note, that you are responsible for ensuring that the record is committed to the
database, prior to sending it for indexing.
Now, let's index the record:
Now, let's index the record. By default, records are sent to the search engine
index defined by the configuration variable ``INDEXER_DEFAULT_INDEX``. This
is set to ``None`` by default, to enforce that you always have to specify the
index when indexing a record. For now let's set it to a default value and index
the record:
>>> app.config['INDEXER_DEFAULT_INDEX'] = "records-record-v1.0.0"
>>> from invenio_indexer.api import RecordIndexer
>>> indexer = RecordIndexer()
>>> res = indexer.index(record)
By default, records are sent to the search engine index defined by the
configuration variable ``INDEXER_DEFAULT_INDEX``. If the record however has a
``$schema`` attribute, the index is automatically determined from this. E.g.
the following record:
If the record however has a ``$schema`` attribute, the index is automatically
determined from this. E.g. the following record:
>>> r = Record({
... '$schema': 'http://example.org/records/record-v1.0.0.json'})
Expand Down

0 comments on commit 8985dd0

Please sign in to comment.