1

I have the following search:

titles = Title.objects.filter(title__icontains=search)

If this is a search to find:

Thomas: Splish, Splash, Splosh

I can type in something like "Thomas" or "Thomas: Splish, Splash, Splosh" and it will work.

However, if I type in something like "Thomas Splash", it will not work. How would I improve the search to do something like that (also note that if we split on words, the comma and other non-alphanumerics should be ignored -- for example, the split words should not be "Thomas:", "Splish," but rather "Thomas", "Splish", etc.

2 Answers 2

1

This kind of search is starting to push the boundaries of django and the ORM. Once it gets to this level of complexity I always switch over to a system that is built entirely for search. I dig lucene, so I usually go for ElasticSearch or Solr

Keep in mind that full text searching is a subsystem all unto itself, but can really add a lot of value to your site.

Sign up to request clarification or add additional context in comments.

Comments

1

As Django models are using database queries there is not much magic you can do.

You could split your search by non-alphanumeric chars and search objects containing all words but this will not be smart and efficient.

If you want something really smart maybe you should check out haystack:

http://haystacksearch.org/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.