0

I have model:

class Article(models.Model):
    title = models.CharField(max_length=250)
    slug = models.SlugField(max_length=250)
    text = models.TextField()
    date = models.DateTimeField(auto_now_add=True)

And file search_indexes.py:

from haystack import indexes
from haystack import site
from models import Article

class ArticleIndex(indexes.SearchIndex):
    text_q = indexes.CharField(document=True, use_template=True)
    text = indexes.CharField(model_attr='text')

    # what I must add here ???

site.register(Article, ArticleIndex)

When I execute query it can find only than words which I have in TITLE field. When I use word combination from TEXT field I got "No results found"

What I must add for executing queries with words from TEXT field?

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
kusha
  • 1
  • 1

1 Answers1

0

The query only looks in the field marked document=True (the other fields can only be used for later filtering)

The documentation recommends naming that 'text'.

As you have use_template=True you should have a template that specifies what object fields are in the document.

e.g. templates/search/indexes/main/article_text.txt could contain

{{ object.title }}
{{ object.text }}
DaveB
  • 190
  • 1
  • 7