0
我很難找回結果。沒有結果django + haystack 1.2.7和solr 3.6.1
這是我到目前爲止有:
search_indexes.py
class CompanyIndex(SearchIndex):
text = CharField(document=True, use_template=True)
name = CharField(model_attr='name')
sector = CharField(model_attr='sector')
def get_model(self):
return Company
def index_queryset(self):
return self.get_model().objects.all()
site.register(公司,CompanyIndex)
class CompanySearchForm(ModelSearchForm):
name = forms.CharField(max_length=64, required=False)
sector = forms.MultipleChoiceField(choices=SECTORS_CHOICES, required=False)
def search(self):
# First, store the SearchQuerySet received from other processing.
sqs = super(CompanySearchForm, self).search()
print "fgdgdfgdfgdfg"
if self.is_valid():
# Check to see if a start_date was chosen.
if self.cleaned_data['name']:
print "%s" % self.cleaned_data['name']
sqs = sqs.filter(name__exact=self.cleaned_data['name'])
# Check to see if an end_date was chosen.
if self.cleaned_data['sector']:
sqs = sqs.filter(sector__contains=self.cleaned_data['sector'])
return sqs
和網址:
sqs = SearchQuerySet()
url(r'^search/', SearchView(
template='search/search.html',
form_class=CompanySearchForm,
searchqueryset=sqs,
), name='haystack_search'),
我' m使用乾草堆文檔中的模板。 我看不到任何結果。
我感謝所有幫助
看來我有同樣的問題,因爲這傢伙: http://stackoverflow.com/questions/7142651/django-haystack-no-search-results 我該如何解決這個問題? – DjangoPy
Solr是否正確設置(您是否使用Haystack生成的schema.xml文件)? 更新索引('./manage.py update_index')是否正常工作? –
是的,我看到我的模型對象被索引。 我認爲它與solr配置有關。 我用碼頭使用端口8080 – DjangoPy