Is it possible to add streamfields to the search index?

933 views
Skip to first unread message

Christoph Lipp

unread,
May 20, 2015, 4:13:39 PM5/20/15
to wag...@googlegroups.com

Hi there

Just read about the search feature in wagtail and the possibility to add custom fields to the index. Can I do the same for a streamfield? It just popped up as a question I didn't have the time to actually try it out :)

Cheers,
Christoph

Matthew Westcott

unread,
May 20, 2015, 4:38:25 PM5/20/15
to wag...@googlegroups.com
Hi Christoph,
Yes - you can add the StreamField field to the list of fields to be indexed, and it should (hopefully) just work. There's logic in place within StreamField to extract the meaningful text content from the field, which by default is all CharBlocks, TextBlocks and RichTextBlocks.

(If you define your own block types, you can customise this behaviour by defining a 'get_searchable_content' method on your block class - see the implementation for the default blocks, at https://github.com/torchbox/wagtail/blob/master/wagtail/wagtailcore/blocks/field_block.py)

Cheers,
- Matt

Christoph Lipp

unread,
May 21, 2015, 2:25:25 PM5/21/15
to wag...@googlegroups.com
Hi Matt

Thank you very much for your explanation, that's amazing!

Best regards,
Christoph

اسامة الزعيم

unread,
Feb 24, 2018, 5:26:47 PM2/24/18
to Wagtail support
hi
link is down can you give another url please.
think you


On Wednesday, May 20, 2015 at 6:38:25 PM UTC+2, Matthew Westcott wrote:

Benjamin Bach

unread,
Feb 24, 2018, 7:18:53 PM2/24/18
to wag...@googlegroups.com, اسامة الزعيم

Dear اسامة الزعيم,

That’s because of a refactor where wagtailcore is now just called core

https://github.com/wagtail/wagtail/blob/master/wagtail/core/blocks/field_block.py

We will probably see a number of similar cases in support responses — so be on the look when transferring advice from Wagtail 1.x to 2.x that these refactors happened.


Best,
Ben

--
You received this message because you are subscribed to the Google Groups "Wagtail support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wagtail+u...@googlegroups.com.
To post to this group, send email to wag...@googlegroups.com.
Visit this group at https://groups.google.com/group/wagtail.
To view this discussion on the web, visit https://groups.google.com/d/msgid/wagtail/138ce29a-8e70-475c-b0db-8016afe12bee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages