Reputation: 1
I'm trying to search through all of my pages on the backend to find instances of urls with outdated domain names. But when I search, it only seems to get hits based on the title of the pages, and not their content. Is there something I need to configure to make this work?
Thank you!
Upvotes: 0
Views: 846
Reputation: 25227
To search on fields beyond the ones that are common to all page types (such as title), you'll need to define a search_fields
property on your page model, such as:
from wagtail.search import index
class MyPage(Page):
body = StreamField(...)
search_fields = Page.search_fields + [
index.SearchField('body')
]
After setting this up, you'll need to update the search index to contain this new data, by running ./manage.py update_index
.
If you're running 2.14.x or earlier, you'll also need to set up an alternative search backend such as Postgres or Elasticsearch - the default wagtail.search.backends.db
search backend was very limited and only supported searching on the 'core' fields such as title. As of 2.15, a new wagtail.search.backends.database
backend is available and enabled on new projects out of the box, and this has full support for searching across all fields.
Upvotes: 3