0

我想为我的网络应用程序实现搜索功能。我选择 Haystack 和 Solr。遵循文档中的过程后。我尝试重建 solr 索引( python manage.py rebuild_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

搜索索引.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 回答