开发者

Django: Haystack or ORM

For a project I implemented Ha开发者_运维技巧ystack 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?


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/


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.


And not forget to mention that doing a basic haystack setup isn't really much more work than doing a search view using Django's ORM.


Haystack is a module that enables easier search integrations for your django application

you can create something similiar to a ModelForm, called ModelIndex, in this new class you will be able to declare the searchable fields of your models and other settings

It has little to do with Django ORM (the orm is used to comunicate with your databases)

of course you can have the orm query your db models with the search pattern specified, but Haystack is a better choice for setting up a search engine easily on your website, so... if you have to enable complex searches on your site, just go with Haystack

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜