django-elasticsearch-dsl icon indicating copy to clipboard operation
django-elasticsearch-dsl copied to clipboard

Multiple websites using ElasticSearch on the same server

Open archatas opened this issue 6 years ago • 4 comments

Can you please update the README explaining how to set up several websites using ElasticSearch so that the indexes don't clash (or should I add website-related prefixes to the documents myself)?

archatas avatar Jun 05 '18 17:06 archatas

@archatas:

Briefly covered here.

You basically override ELASTICSEARCH_INDEX_NAMES setting for your environments. Prefixing works fine for me.

dev

ELASTICSEARCH_INDEX_NAMES = {
    'search_indexes.documents.address': 'address',
    'search_indexes.documents.author': 'author',
    'search_indexes.documents.book': 'book',
    'search_indexes.documents.city': 'city',
    'search_indexes.documents.publisher': 'publisher',
}

prod

ELASTICSEARCH_INDEX_NAMES = {
    'search_indexes.documents.address': 'prod_address',
    'search_indexes.documents.author': 'prod_author',
    'search_indexes.documents.book': 'prod_book',
    'search_indexes.documents.city': 'prod_city',
    'search_indexes.documents.publisher': 'prod_publisher',
}

barseghyanartur avatar Jun 25 '18 11:06 barseghyanartur

Does the command to rebuild index work well in a case of multiple websites indexed with different index prefixes? For example, I might want to rebuild index for example.com. but not for example.org, where these are different Django projects deployed on the same server.

If I run

python manage.py search_index --rebuild

on one website, will it keep the indexes from another website?

archatas avatar Jun 25 '18 13:06 archatas

It will remove only indexes listed in the ELASTICSEARCH_INDEX_NAMES. It's also a good way of separating your test environment from dev (or any other).

https://github.com/barseghyanartur/django-elasticsearch-dsl-drf/blob/master/examples/simple/settings/testing.py

barseghyanartur avatar Jun 25 '18 13:06 barseghyanartur

Is possible to have more elasticsearch servers in conf?

Allan-Nava avatar Mar 03 '20 15:03 Allan-Nava