mysociety / yournextrepresentative

A website for crowd-sourcing structured election candidate data
https://candidates.democracyclub.org.uk/
GNU Affero General Public License v3.0
56 stars 21 forks source link

Fix searches featuring apostrophes #870

Closed struan closed 8 years ago

struan commented 8 years ago

The search uses the text field in the index which is generated by Haystack and escapes the content as it goes in. Search terms were not being escaped which meant that names with an apostrophe in them never matched.

This escapes search terms so they should not match the values in the text field in the search index.

Fixes #862

mhl commented 8 years ago

Just a comment asking for a comment, :speech_balloon: otherwise this looks good :+1:

sjorford commented 7 years ago

This doesn't seem to be working on candidates.dc - e.g. searching for "Fiona O'Donnell" doesn't find https://candidates.democracyclub.org.uk/person/839/fiona-odonnell

mhl commented 7 years ago

@sjorford Thanks for pointing that out - this commit (390f7ded63d57efd4b8) is only in upstream, which is why the search fails on the DC fork. @symroe - I think if you cherry-pick that commit onto DC master, it should fix the problem there too, since:

curl "http://localhost:9200/_search?q=Fiona%20O%26%2339;Donnell&pretty=1"

... does find the candidate.