Search: pages missing from results when titles contain signed numbers
Issue summary
Some pages don't list as results when submitting a search query.
Pages with numbers in the title can sometimes not be found in search results. This only appears to be the case when the number is immediately prefixed by a hyphen (i.e. <page title>-123). When searching for the exact page title, the page will not be shown in the results.
I believe this is because:
- search queries may somehow represent numbers in such a way that they are always unsigned (i.e.
-123will be represented as the token123) - page titles may somehow represent numbers as signed (i.e.
-123will be represented as the token-123)
Therefore when searching for the page page-123, the search query is interpreted as 123 and the page title is interpreted as -123, meaning these tokens don't match and the page is not shown despite the search text and title text being identical.
Steps to reproduce
- Open wagtail admin
- Create two pages of any type, with titles e.g.
page-1andpage 2(note one has a hyphen immediately before the numerical suffix, and the other does not) - Try to search for each of these pages with the exact page title.
- Observe that only
page 2appears in search results. - Observe that searching for
pagewill show both pages in the search results. - Observe that searching for
1and then2will only yieldpage 2. - Observe that searching for
-1will not yieldpage-1.
Additional information
Searching for the exact page title should yield the page in search results
Can be reproduced
Yes, on the bakerydemo
Technical details
Reproducible on the latest bakerydemo
Working on this
If you would like to contribute to this issue, follow these steps:
- Confirm that the issue is reproducible, either on a fresh Wagtail project or the bakerydemo.
- Once confirmed, view our contributing guidelines, add a comment to the issue once you're ready to start.
Source: wagtail/wagtail