Skip to content

Fix 500 error when searching for words containing apostrophes#76

Open
Adithya00012 wants to merge 1 commit intowagtail:mainfrom
Adithya00012:fix/autocomplete-apostrophe-search
Open

Fix 500 error when searching for words containing apostrophes#76
Adithya00012 wants to merge 1 commit intowagtail:mainfrom
Adithya00012:fix/autocomplete-apostrophe-search

Conversation

@Adithya00012
Copy link

Fixes wagtail/wagtail#13956

Description

When searching for words containing apostrophes (e.g. it's) in the Wagtail
admin sidebar search with Elasticsearch, a 500 error was raised with
NotImplementedError: 'And' is not supported for autocomplete queries.

parse_query_string was splitting on all apostrophes, treating it's as
And(PlainText('it'), Phrase('s')). The Elasticsearch autocomplete backend
does not support And queries.

The fix updates parse_query_string to only split on apostrophes that are
NOT inside a word, using regex lookahead and lookbehind. Mid-word apostrophes
like it's are now treated as plain text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant