Where next for Wagtail Search?
Transcript
By Speaker 1, Speaker 2. From Wagtail Space 2025. Published November 19, 2025.
Watch the video Markdown version 4,457 words · auto-generated · en
Summary
Wagtail Search was built to provide search beyond basic database text matching, including stemming, relevance ranking and integration with Django query filters. Database backends avoid maintaining a separate search index but have limitations such as searching only a combined indexed text field, while Elasticsearch and OpenSearch bring synchronization, query-translation, compatibility and scaling challenges. Matt described moving the search functionality into the standalone Django Model Search package with its original developer, Carl Hobley, to improve documentation, testing and backend support while keeping Wagtail upgrades compatible; he sees this as groundwork for addressing technical debt and future needs.
Transcript
Automatically transcribed, so expect mistakes in names and technical terms. Filler words are removed.
0:00 Wagtail’s Design Principles
Speaker 1
Let's get started. Hello everyone. I hope you've been enjoying Wagtail Space today. I'm Ian , the Chief Growth Officer for Wagtail at Torchbox. And I have the great pleasure of introducing Matt Westcott, our Wagtail Tech Lead. He's going to tell you where next for Wagtail Search. Matt is a member of the Wagtail Core team. He's been working on Wagtail since day one, over a decade ago. And if you have questions for Matt during the talk, please put them in the Q<unk>A. Over to you, Matt. Thanks
Speaker 2
Ian. I'm gonna eat. So find my window to share. Hopefully you should be seeing that now. Yep, so yes, as Ian said, I'm I'm Matt. My pronouns are he, him, I'm the tech lead on Wagtail and one of the original developers on the project, and you might also have seen me around under the name Gasman. I won't explain that one. So I've spoken a fair bit about the guiding principles behind the creation of Wagtail at previous talks and writings like The Zen of Wagtail But if there's one strand that runs through all of them, I think it might be this. Choose your battles So the main battle that we took on was to create a great interface for authoring web pages.
But one battle that we decided not to take on was creating a great user interface for defining the data model. of a web page. We decided that writing that in code was good enough. Could there be a better system? Maybe, but that wasn't a problem that we were trying to solve. Likewise, we didn't take on the battle of making a tool for doing page layout in the browser. We felt that HTML and CSS would serve that purpose and we didn't see a need to replace them But if other folks, like Code Red, for example, see an opportunity to fill that gap and make Wagtail into a user interface for page layouts, that's great. Everyone can choose their own battles.
There is a pool of wisdom from the days when everyone was running their own blogs saying to never write your own CMS. Now, obviously if we if we'd followed that advice ourselves and if the Royal College of Art hadn't made the leap of saying We've evaluated all the CMSs and they suck. We want you to build us a new one. That might not have been their exact words. Then there would never have been a white tail. We could maybe revise that statement to never write your own CMS unless you're on board with becoming the guy who makes a CMS. possibly to the exclusion of everything else, beginning with that blog that you were intending to write in the first place before you got distracted by making a CMS.
Now one battle that I really wish we could have taken on and I still think someone should pick up is a really good video management system for Wagtail dealing with things like transcoding, large file handling, thumbnails, subtitles, and so on. As Tom showed in his talk yesterday, the building blocks are basically all out there. But doing all of that would have been a pretty sizable project that it that essentially runs parallel to Wagtail itself And that was a distraction that we didn't really need. And for most purposes, embedding videos from YouTube or Vimeo is a workable solution. All of which brings us to search. It's an essential ingredient of any content-based site, and yet it's
3:54 Why Wagtail Built Search
Speaker 2
another separate parallel problem to the task of getting can content into a site. And in this case, there wasn't really an existing solution that handled this adequately We wanted to be able to perform search queries as easily as Django allows us to make database queries being able to just take the existing ORM syntax and just add in this search clause to be able to search any model that we have this set up on. So in the end, this was one more battle that we chose to take on. Now this was the work of Carl Hobley, another of the original Wagtail developers
And as I said, it it's a problem that makes sense to tackle independently of the rest of Wagtail And so while this has always been shipped as an app within Wagtail, there's very little about it that's specific to Wagtail. And unlike many of the other subaps of Wagtail that you're used to, like images and documents that depend on the Wagtail core and admin modules to function. For the search module, it's actually the other way around. Wagtail Core is built on top of Wagtail Search as a building block. And this meant that we, in principle, we always had the possibility open to split it out into its own standalone projects, which
sounds kind of attractive, but it's the sort of thing that you would only want to do once we felt that it was stable enough and it had proved its worth within Wagtail. And like many sort of things in Wagtail's development, that has always remained this sort of nice to have pipe dream. Other more practical concerns have always tended to take priority over th those sorts of things So what makes this such a tricky problem that apparently no one had solved already? Well, we didn't want to be limited to the functionality of the database itself. A best in class search implementation isn't just about matching strings of text.
6:14 What Makes Search Effective
Speaker 2
You also need to take care of details like stemming and synonyms, so that's tweeting similar words such as bake, baker, baking, bakery, all as equivalent so that you're not missing out on relevant results if you don't happen to use the exact same wording as the page does. Also ranking results based on like proximity and frequency of search terms. So if you're searching for pages about banana bread, yes, I'm going for the bakery demo analogies again. You probably want to favor text where the words banana and bread are in close proximity, not pages that mention bananas in the first paragraph and bread somewhere in the tenth.
These are often invisible details that users wouldn't think about and even developers would rather not have to think about. But search results will just seem off if you don't get them right This behavior is often complex and unintuitive. We sometimes have clients questioning the micro details of search results, asking things like Well this page has the word banana in it twice, so that should be ranked above this other page that only has it in once, right? And yeah, it's not quite as simple as that. There's all sorts of factors that You can't really product on predict on anything more than more than vibes, really.
7:47 Search Engines and Query Translation
Speaker 2
So for a long time these features were only really available in standalone search engines such as Elasticsearch. And that meant that for your site's data to be searchable, you had to keep this separate parallel copy of your site content within Elasticsearch 's data store. So firstly that meant that you had to keep that copy in sync with your database as the primary source of truth. Usually that's not a big deal. We have a management command to do that initial population. And we can use Django signals to respond to individual pages being created or updated and push that to Elasticsearch as needed. But secondly, you have to get a little bit creative when
you're making queries that combine text search with database style filtering in the more conventional sets. For example, if you want to search for pages created in the last six months, that would be a query like so take the page dataset, filter that by ones with the first published at greater than the April the 9th, and then search that dataset for The word baguette. And Django knows how to turn that filter expression into a SQL query to run on your database. But we want this query to happen on Elasticsearch
and Elasticsearch doesn't talk SQL. So inside this search method, we have to pull apart that query object that we've already constructed up to that point and translate that into the JSON query that we can send to Elasticsearch. And that requires digging into a certain amount of Django internals to do that sort of translation. And so that means that Elasticsearch has to keep a copy of even more of the database contents to allow it to do these queries based on these other fields. And also a large chunk of the logic that exists in Django for making sense of these filters had to be replicated in Wagtail's search module.
10:10 Database Search and Its Tradeoffs
Speaker 2
Now over time the databases that we use within Wagtail, so that's Postgres, MySQL, SQLite started y adding their own full text search functions and those were made available within Django and so in Wagtail 2. 15 Following a Google Summer of Code projects from Al Dan Creo, we added a database backend that's now the default one for new WhiteL projects out of the box, which adapts to whichever database you're using and calls the relevant full text search functions from that database. It's always been a key design goal of Wagtail Search that all backends work in the same way.
It should be possible to switch from one to another without changing any code. That's a goal that we've had mixed results, mixed success with as each backend comes with different challenges and points of friction. If you're running a full text search directly in the database, then on the one hand you don't have that problem from Elasticsearch of keeping two data sources in sync and translating queries from one format into another. On the other hand, because databases have this sort of much more rigid structure where the schema has to be defined up front. That means that the way we have search set up, we essentially have a single field that holds all of the indexed content of a page
in a form that can be queried. It's all like one big pot of tokenized text soup that doesn't really keep track of which fields that text originally came from. And so it's not currently possible to run searches that just search the title or just search the summary field or whatever it may be because If you're searching, you're searching on everything that we indexed for that particular page. So Carl, the primary developer of Wagtail Search, left Torchbox to move on to other things and left the Wagtail project along with it. And this is where we encountered the bus factor in full effect and the hazards of taking on one battle too many.
12:35 Search Challenges and Admin Use Cases
Speaker 2
So we lost a lot of the institutional knowledge about Wagtail Cert that Carl had and Really that's not the only fact that has held back developing Gwytel Search in the way that we wanted to But one thing, Elasticsearch has been a bit of a moving target. In Elasticsearch 5, if you wanted to boost a given field in the results so that for example a search term that matches the page title appears in the results with higher priority. It used to be that you'd set that up at indexing time and then you would have that take effect on any queries you perform afterwards But as of Elasticsearch 6, they suddenly deprecated that whole thing and
now they want you to specify the boosting rules at the point of making doing the search, which didn't at all match how we have the search index set up. And it took us a long time to catch up with that and restore the boosting functionality in later versions of Elasticsearch. And they also moved the goalpost on the license, switching to a commercial license that made it unusable by organizations like Amazon Web Services. So in response they created a fork. which is OpenSearch, which was backwards compatible with Elasticsearch seven, meaning that we could use the same backend and client libraries. At least that was the case up to version 7.
13. 5 of the client library which doesn't sound like the sort of version number way would be making massive breaking changes, but that's when they just decided to shut out anything that wasn't an official Elasticsearch server. So you could continue using the older version of the client library with open search, but obviously that's not a great solution as these versions reach end of life and You want to carry on using a supported version of OpenSearch. And WagTail's own ambitions have expanded in this time in a way that the search module hasn't really kept up with When we redesigned the page listing view in Wagtail 5.
2 and later extended that to other listings in 6. 0, we put searching front and center. And at this point search isn't just a way of discovering information, it becomes a primary tool for navigation, for getting around the admin. And there may well be occasions when those two goals are at odds with each other. So take this scenario in the screenshot. If you know that you want to edit the baguette page then being able to just type in the start of the word baguette and head straight there is a major speed boost to using the admin. But if you're performing a search in the conventional sense of
knowledge discovery and you want to know like what pages do we have that talk about bags. it probably isn't helpful to have results about baguettes mixed in there. So maybe that's something that we can handle with intelligent rankings promoting the exact word matches over the partial ones. Or maybe this calls for a rethink of the UI such that so that running a search is a deliberate step that's distinct from getting these results continuously as you type. Because this particular user interface is actually a fairly uncommon one. Usually you would see a sort of drop down by the search the by the search box. with the auto-completed results
16:28 Tree Filters and Search at Scale
Speaker 2
and actually getting search results is a separate step. So maybe that's something that we need to think about adopting. This is all something that we're going to have to decide. Another aspect that may not be at all obvious on this screenshot is that here we're searching the d specifically the breads section of the of the website. So if so that would be transl again that this is filtering to just this section is something that we need to do as a sort of classical database query, which then if you're running Elasticsearch, is then
passed to Elasticsearch to run. So that code would look something like this sort of descendant of Bread's index and run an autocomplete search on that. But this anything that's of involving querying the tree structure that's reliant on the Django tree beard library and that one is doing all sorts of complex querying and different and esoteric filters behind the scenes that we don't currently support in i in the elastic search back end So there's a sort of nuclear option we can go for at this point, which is to do the initial query to find the
candidate pages. in on the database and then pass Elasticsearch this list of IDs. Okay, do this search but restrict it to IDs 100, 101, 102, 103, 104. That's the sort of query that it's you can get away with if you have a hundred or maybe a thousand pages in this section. But once you reach a certain size, if you get into sort of it tens, hundreds, thousands, millions, then that's all going to fall over and this is really a kind of worst case scenario for of for putting a site into production if it only breaks once you reach a certain size of real-world usage.
18:48 Extracting Django Model Search
Speaker 2
And unfortunately this is something that that some clients have raised as their sites have hit a certain size. And this is still an open project problem that we're we're hoping to sort of tackle in the near future. So yeah, the for the White Tail seven point two release Search has been my primary focus. There's kind of a lot of technical debt that we've needed to address. And top of that list is the pipe dream that we never got around to all those years ago, which is splitting out Wagtail Search into its own package. And this is not just good for people
using search on Django projects outside of Wagtail. this is a profound improvement to the way that we develop Wagtail 2. So one example being testing. So as I mentioned, we want all backends to work interchangeably as far as possible. And in an ideal world, we'd verify that by running the complete white tail test suite under each back end. But not only is that A lot of tests to run on the on GitHub Actions once you consider all of the backends and versions of search engines we want to support. because we do care about our green credentials after all. It's also not quite as simple as that in practice, because
as I mentioned earlier, search ranking algorithms have this black box aspect to them And that's a feature, not a bug. If Wagtails unit tests expect a particular ordering, but on one search eng one search back end results number nine and ten happen to be switched around. Well, that shouldn't really be considered a test failure. But there's lots the way that Wagtails tests are written, they're it are writ in this very sensitive way where it will flag up if results are slightly different or is there w there are one more or one fewer query happening. So it's kind of in practice it's very difficult to take our existing Wagtail test suite
and expect that to work across all backends So by having Wagtail Search in its own test harness, its own test front independent of Wagtail, we can be a lot more thorough and careful. and fine-grained about how we define what it means for functionality to be correct and how we define successful tests. So I've been able to do to make a lot of progress on that with this as an independent library and I've been improving the test coverage and documenting the internals. as we go, again hopefully avoiding the reliance on this previous undocumented in institutional knowledge.
21:54 Joining Forces with Carl
Speaker 2
But in fact, this is already old news because it seems that as I was setting up this new GitHub repo and moving old issues from the Wagtail repository to this new one some of those old issues naturally had Carl C C'd on them and that caught his attention and so he popped up on the Wagtail Slack asking you do know I've been working on the same thing, right? And yes, indeed, so s since early this year he's been working on this project Django Model Search. which had the same goal of taking Wagtail search functionality, moving that into its own package. And so we decided to join forces on this project.
And clearly there was a bit of face palming that we'd been duplicating work, but in fact this was the best possible outcome. Because so firstly, we don't lose Carl's institutional knowledge after all. And as Carl's focus has been on making it work independently of Wagtail, he's made some substantial improvements to the documentation. And meanwhile, my focus has been more on making the transition from Wagtail Search to Django model search as smooth as possible. And my aim is that when you upgrade to the next version of FigTale that uses this, you won't have to make any changes to your installed apps settings or change any imports around. Everything should just work as before.
23:25 Search Improvements and Future Directions
Speaker 2
And yeah we're having some good success with that. Just in the last week we've got the full Wagtail test suite running successfully against Django model search. So this is really only the start of the process of improving our search functionality. There is there's lots of the bugs that we want to address and catching up on new search backends new newer versions of search engines. And we've already seen the initial fruits of that work. So we now support Elasticsearch 9 and crucially Elastic OpenSearch 2 and 3 using the native client library
Rather than the old outdated version of Elasticsearch 7 But really this is just the beginning of what we want to do. I think as no talk would be complete without a mention of AI and while the yeah doing being able to query to l LLMs and vector indexes to actually get different kinds of results is that's not exactly the s the kind of search that would fit into the API that we already have, but given that we already have this existing mechanism in elastic for Elasticsearch for being able to push
data into this external data store and keep that in sync. That is something that we can definitely benefit from if we decouple that that bit of functionality from the actual searching logic. But yeah, really this is just for now it's it's mostly about improving Wagtail's development process And yeah, it's really exciting to have Carl sort of back on board indirectly on the White Hill project and having the this the extra outside perspective as well to for to develop Django model search in a way that benefits both Whitetail and
and for the wider Django ecosystem. So yeah, it's I'm really looking forward to seeing how that all develops. And that's me. Thank you very much.
25:58 Questions
Speaker 1
Thank you, Matt. That was a really fascinating look into an important aspect of Wagtail. We've got time for a few questions. The first one if you could just can you just confirm when will we see these improvements released?
Speaker 2
yeah, so we so the plan is for at least the integration of Django model search to ship as part of White tail seven point two next month and is it next month or December? I was like yeah, it's next month. And hopefully at least some of the tangible improvements beyond the Elasticsearch and OpenSearch as well. But yeah. Can't say for sure on that, but yeah, this is definitely a longer term thing for getting all of the technical debt sorted.
Speaker 1
Great, thanks Matt. Is Elasticsearch or OpenSearch a requirement to get full text search using Wagtail Search?
Speaker 2
No, that's so the database backends that are they all support f full text search. There are Currently some limitations, I think the one I mentioned being it doesn't support searching on individual fields, but yeah, the s the searching the underlying functions in the database backends are that they're sort of on a par with what we have for in Elasticsearch so that you do get that. with just the database without Elasticsearch or OpenSearch.
Speaker 1
Next question. Any tips or resources for creating filters or facets for a Wagtail search UI? Will Django model search help with that, maybe with a combination with Django filters?
Speaker 2
Right. Oh no, that's an area I've not really looked into. We there are there is faceting support in i in White Tail Search that has now made it into Django model search. It's not really something I've looked deeply into, but yeah, I th I think that is that that that should work nicely in conjunction with Django filters. Ultimately that what you select in Django filters will be translated into filter expressions. So as long as th those are not too complex, then that should be the supported with all the backends.
Speaker 1
Thanks, Matthew. We've just got time for a couple more questions. Will Django model search support database backends?
Speaker 2
yeah, so yeah, they the plan is very much to ensure that everything is backwards compatible with how things worked. In WhiteL search. And yeah, so the database backends will they're they're here to stay. So we We've reintroduced the MySQL backend which was temporarily taken out, but that's all back in now. So yeah, everything that has previously worked will continue to.
Speaker 1
Great. And just one more question before we have to wrap up this session. Are there any plans to support multiple index versions of the same page to deal with different setups for the admin and front end or multiple languages?
Speaker 2
Yeah, I think we do want to handle that sort of thing. I know Baptiste who has recently joined Torchbox and is a l a long time Django dev on the on the on the on Django Core is keen to look into that side of things. So yeah, I think we definitely want to we w I don't n know exactly how that's going to look yet, but I think Baptiste has some ideas and yeah, I'm sure we can make that work.
Speaker 1
Great. Thank you, Matthew. That was a really fascinating look at the history and the future of Wagtail Search.