toastdriven/django-haystack — pull request #518 by madanthangavelu (2012-02-26 21:39:39+00:00)
Title: Haystack manager

Daniel,

This patch allows one to query in a similar manner to that of django.

class MySearchIndex1(indexes.SearchIndex, indexes.Indexable):
author = indexes.CharField(model_attr='author')
pub_date = indexes.DateTimeField(model_attr='pub_date')

def get_model(self):
return MockModel

class MySearchIndex2(indexes.SearchIndex, indexes.Indexable):
author = indexes.CharField(model_attr='author')
pub_date = indexes.DateTimeField(model_attr='pub_date')

def get_model(self):
return MockModel

class meta:
index_label='different_connection_name'

We can now query as below:
MySearchIndex1.objects.all()
MySearchIndex2.objects.filter(*kwargs).narrow('something')

I wanted to get familiar with haystack testing but I was not sure where tests related to this pull request should go. I ran the core tests and they passed.

The query.py tests deal directly with BaseSearchQuery and indexes.py do not test any querying. If you think I am missing an obvious place to add tests, please do suggest. This is my experimental patch to get used to haystack.