1

私はHaystack2.0.0betaのドキュメントを調べ、バックエンドとしてsolr3.6.0を使用しています。はじめにの例を完了しました。ファセットの例を使用しています。

search_indexes.py

import datetime
from haystack import indexes
from bsmain.models import Note

class NoteIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    author = indexes.CharField(model_attr='user', faceted=True)
    pub_date = indexes.DateTimeField(model_attr='pub_date')

def get_model(self):
    return Note

def index_queryset(self):
    """Used when the entire index for model is updated."""
    return self.get_model().objects.filter(pub_date__lte=datetime.datetime.now())

urls.py

from django.conf.urls.defaults import *
from django.conf import settings

from django.conf.urls.defaults import *
from haystack.forms import FacetedSearchForm
from haystack.query import SearchQuerySet
from haystack.views import FacetedSearchView
sqs = SearchQuerySet().facet('author')

urlpatterns = patterns('haystack.views',
    url(r'^$', FacetedSearchView(form_class=FacetedSearchForm,searchqueryset=sqs),
        name='haystack_search'),
)

Pythonシェルでテストし、ファセットとカウントを取得しましたが、/ search url(ファセットの例で提供されているhtmlを使用)を起動すると、フォームは取得されますが、ファセットまたはカウントは取得されません。誰かが上記のコードに何か問題があるのを見ることができますか、それとも私が見逃している何かがありますか?

ありがとう。

4

1 に答える 1

0

インデックスを再構築しましたか(./manage.py rebuild_index)?

完了したら、schema.xml(./manage.py build_solr_scema > schema.xml)を作成します

次に、shcema.xmlをsolr confディレクトリーにコピーして、solrを再始動します。

それはあなたの問題を解決するはずです。

于 2012-07-16T15:02:16.933 に答える