picomon
picomon

Reputation: 1519

Haystack and Solr- Fail To Clear Index

I wanted to implement a search feature for my web app. I choose Haystack and Solr. After following the procedure in the docs. I tried to rebuild solr index ( python manage.py rebuild_index ) but I'm getting the below error. What I'm I missing?

   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 settings

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

Models

     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())

Upvotes: 0

Views: 1115

Answers (1)

mutantacule
mutantacule

Reputation: 7063

Then first of all, try to get solr running.

Upvotes: 1

Related Questions