divio / aldryn-search

Haystack 2.0 search index for django CMS
Other
48 stars 77 forks source link

Documentation on HAYSTACK_CONNECTIONS #36

Open jrief opened 9 years ago

jrief commented 9 years ago

if haystack is used in conjunction with Elasticsearch, the shown configuration settings

HAYSTACK_CONNECTIONS = {
    'en': {
        'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
        'URL': 'http://localhost:9200/',
        'INDEX_NAME': 'haystack-en',
    },
    'fr': {
        'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
        'URL': 'http://localhost:9200/',
        'INDEX_NAME': 'haystack-fr',
    },
}

will give a very weird error:

  File "lib/python2.7/site-packages/haystack/__init__.py", line 6, in <module>
    from haystack import signals
ImportError: cannot import name signals

Instead declare one of the search-indices as default, say

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
        'URL': 'http://localhost:9200/',
        'INDEX_NAME': 'haystack-en',
    },
   ...
}
czpython commented 9 years ago

@jrief the need for a default connection is documented in haystack, we can extend our example in the readme to include the default connection.