Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: Haystack or ORM

Tags:

search

django

For a project I implemented Haystack but now I was wondering what the pros and cons are of using Haystack over the ORM. For my project I need to find books by their title and isbn. I guess Haystack is more useful if you have to do full text searches or am I missing something?

like image 975
Pickels Avatar asked Sep 04 '25 17:09

Pickels


2 Answers

Haystack is certainly better for full text search, and also provides a bunch of other benefits that you won't get using the ORM. Here are some from the Haystack site:

  1. Spelling suggestions
  2. Faceting
  3. More like this
  4. Highlighting
  5. Search term boosting

Besides that, you should use Haystack over the ORM if you expect a high volume of searches, since you'll offload all that work from the DB (which should be focused on writing and retrieving your data).

http://haystacksearch.org/

like image 120
John Debs Avatar answered Sep 07 '25 16:09

John Debs


The main advantage to use haystack over the ORM is performance. LIKE requests are just going to kill you database if you have 100 concurrent users searching. If you have MYSQL of course you can still use its full text capability, but it will still be slower than Xapian or Solr.

Plus you will have additional features such as fuzzy searching that user loves a lot.

It does comes with the extra work of setting up solr and maintaining it, so:

  • if your website is going to be small forever, like for small company intranet, don't bother and user ORM.
  • if you plan for the big bad Web, go Haystack.
like image 21
e-satis Avatar answered Sep 07 '25 17:09

e-satis