-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable fuzzy string searching/matching for areas #101
Comments
I also think this would be a really useful feature and is not that difficult to implement, so I decided to add it. I've not submitted it as a pull request (yet) because I've used the djorm-ext-pgtrgm package ( https://pypi.python.org/pypi/djorm-ext-pgtrgm/0.3 ), which adds support for queries using the pg_trgm extension to Django's ORM. Unfortunately this package doesn't yet support Django 1.8 and I don't want to submit a pull request which would break MapIt's support for Django 1.8. That said, I've submitted a pull request to the djorm-ext-pgtrgm project ( jleivaizq/djorm-ext-pgtrgm#17 ) proposing a fix to resolve the Django 1.8 compatibility issue - so I will keep an eye on that. Hopefully the author will merge it and update the package. If/when that happens, I'll submit a pull request for this feature. A few more notes on what I've done:
I've mapped this to the endpoint /fuzzyareas as a suggestion, but you could change the endpoint if you wanted. This would allow MapIt to tolerate spelling mistakes/partial input e.g: Results are returned sorted by relevance. Let me know if you're interested in taking this forward. |
djorm-ext-pgtrgm has been updated for Django 1.8 compatibility but pypi version is some way behind version on github. |
Thanks for looking at this :) Some random notes as I take a look: This would certainly be nice to have, I think :) |
Cheers – once I've spent some time working through this I'll get back to you on the points you've raised here. |
Apologies for overlooking this. I think I missed it because postgresql-contrib is a recommended package for PostGIS ( http://packages.ubuntu.com/trusty/postgresql-9.3-postgis-2.1 ). Ubuntu installs recommended packages by default so it will usually be installed in the setup process for MapIt anyway - so I don’t think this point requires any additional action, unless I have missed your point.
Full text queries can be performed in Postgres without an index (unlike MySQL for example where you must create a full text index before a full text query can be performed). Obviously using an index will be faster. You can create a suitable index using a command like:
GIN being the more sensible choice than GiST for this situation. I don’t think you can create an index like that through Django so I guess this would be another manual step, unfortunately.
I have done a quick test with a python 3 virtualenv to see if applying the change in jleivaizq/djorm-ext-pgtrgm#6 fixes this but it appears there are other problems. This may be why that PR is not merged. I need to spend a bit more time on this than I’ve been able to so far to work out the best approach from here. Perhaps I should take back that 'not that difficult to implement' comment :)
A parameter is probably more sensible. I’ll modify urls.py accordingly when I next update the pull request. |
Sorry it has taken a bit of time to get back to this. I don't know if that influences your view on whether it is best to pull the library in as a submodule or if you would still prefer to fetch the module from pypi using pip? |
Searching by string prefixes is great but not nearly as useful as fuzzy string searching would be. Fuzzy string searching makes it possible to geocode with data that includes misspellings and variations.
Read this question on GIS.SE for more background on this request.
The text was updated successfully, but these errors were encountered: