Skip to content

Changing a document's index temporarily #26

Answered by qcoumes
johnsonjackc asked this question in Q&A
Discussion options

You must be logged in to vote

I usually set up another Opensearch instance for tests, and add it to the OPENSEARCH_DSL config dict.

Then I can use it in my tests with the using kwarg.

For instance, here is my pytest fixture to handle creation/deletion/indexation in my tests:

@pytest.fixture
def setup_opensearch(db):
    """Return a function allowing to rebuild Elasticsearch Index

    Each function has the following parameters:
    using: string
        Opensearch connection to use as defined in the `OPENSEARCH_DSL` setting.
    indices: List[str]
        Names of the indices that should be created/deleted/populated. If None
        are provided, execute the action on all the index of the registry.
    index_names: Di…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@johnsonjackc
Comment options

Answer selected by johnsonjackc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants