Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to achieve multi-databases queries #1110

Open
larryhq opened this issue Nov 13, 2014 · 3 comments
Open

How to achieve multi-databases queries #1110

larryhq opened this issue Nov 13, 2014 · 3 comments

Comments

@larryhq
Copy link

larryhq commented Nov 13, 2014

My software environment :
python3.4.2 Django:1.7.1 django-haystack:2.3.1
I know how to config multi haystack collections in my project
and know how to config multi databases in my django
but when i use haystack search my data , how to achieve full search.
Thers are lots of databases in my project,but when i search data use haystack ,it seach only defaut database every time . How to achieve multi databases queries?
Thanks .

@dwickwire
Copy link

Can you import the model from the other DB that you need access to and use that model in your index?

@larryhq
Copy link
Author

larryhq commented Nov 14, 2014

My DB config in django is like this:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '{}_default'.format(PROJECT_NAME),
        'USER': 'root'
    }
}

DB_MOD = 4
for i in range(DB_MOD):
    db_dict = DATABASES['default'].copy()
    db_dict['NAME'] = '{}_{}'.format(PROJECT_NAME, i)
    DATABASES['db_{}'.format(i)] = db_dict

There are five databases in my project and all of the databases has the same fabric。
In Django use using(db) method can choose the database which i want. but I don't know when I use haystack ,how to choose the database which i want. The search engine I used is solr4.10.2,the config is

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
        'URL': 'http://127.0.0.1:8983/solr'
        # ...or for multicore...
        # 'URL': 'http://127.0.0.1:8983/solr/mysite',
    }
}

Now I want to search data from all databases, How to config , And Is it support like this?

@Bearbobs
Copy link

following. having same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants