0

Webアプリの検索機能を実装したかったのです。HaystackとSolrを選択します。ドキュメントの手順に従った後。solrインデックス(python manage.py restart_index)を再構築しようとしましたが、以下のエラーが発生します。何が足りないの?

   WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'.
   Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.
   Are you sure you wish to continue? [y/N] y

   Removing all documents from your index because you said so.
   Failed to clear Solr index: [Errno 10061] No connection could be made because the   target machine actively refused it
   All documents removed.
   Indexing 2 fincribs.
   Failed to add documents to Solr: [Errno 10061] No connection could be made because the target machine actively refused it

干し草の山の設定

   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',
    },
 }

モデル

     class Fincrib(models.Model):
           user=models.ForeignKey(User)
           title=models.CharField(max_length=250, unique=True)
           address=models.CharField(max_length=200)
           city=models.CharField(max_length=200)
           state=models.CharField(max_length=200)
           main_view=models.ImageField(upload_to="photos",blank=True, null=True)
           side_view=models.ImageField(upload_to="photos",blank=True, null=True)
           pub_date=models.DateTimeField()

           def __unicode__(self):
               return self.title
          def get_absolute_url(self):
              return self.title

Search_index.py

         class FincribIndex(indexes.SearchIndex, indexes.Indexable):
               text=indexes.CharField(document=True, use_template=True)
               address=indexes.CharField(model_attr='address')
               city=indexes.CharField(model_attr='city')
               state=indexes.CharField(model_attr='state')
               pub_date=indexes.DateTimeField(model_attr='pub_date')

               def get_model(self):
                   return Fincrib
               def index_queryset(self):
                   return self.get_model().objects.filter(pub_date__lte=datetime.datetime.now())
4

1 に答える 1

1

まず、solr を実行してみます。

于 2012-06-21T14:48:32.247 に答える