113

I'm building a Django project that needs search functionality, and until there's a django.contrib.search, I have to choose a search app. So, which is the best? By "best" I mean...

  • easy to install / set up
  • has a Django- or at least Python-friendly API
  • can perform reasonably complex searches

Here are some apps I've heard of, please suggest others if you know of any:

I'd also like to avoid using a third-party search engine (like Google SiteSearch), because some of the data I'd like to index is for site members only and should not be public.

Justin Voss
  • 6,084
  • 6
  • 32
  • 37

15 Answers15

104

Check out Haystack Search - a new model based search abstraction layer that currently supports Xapian, Solr and Whoosh. Looks like it's well supported and documented.

Tathagata
  • 1,815
  • 4
  • 22
  • 38
kpw
  • 1,205
  • 2
  • 9
  • 7
  • 3
    Haystack is under active development and the author is always available via the email list. – Tom Sep 09 '09 at 14:12
  • 2
    From djangosearch project: "This project is no longer under active development. If you're looking for a django full text search application that works with multiple search engines, check out haystack. If you're looking for something specific to Solr, you might want to try solango. " – Esteban Feldman Mar 07 '10 at 14:54
  • Haystack has been badly, if at all, supported for quite some time. I recommend you avoid it at this point. Maybe they will fix it in the future but its in a bad place now. – Aaron Schif Jul 31 '13 at 15:21
  • I agree, the latest version of haystack (2.1) is not working at all with my python 2.7 version of django 1.4. – Chris Hawkes Aug 18 '13 at 02:13
19

Justin, I'd try djangosearch first: Jacob Kaplan-Moss (Django's lead developer) is working on it.

Potential hazards:

  • The home page warns the API might not be entirely stable

Potential benefits:

  • “The long term goal is for this to become django.contrib.search.”
Garth Kidd
  • 6,742
  • 4
  • 32
  • 36
  • 46
    The page now says "This project is no longer under active development. If you're looking for a django full text search application that works with multiple search engines, check out Haystack." – Tomas Andrle Jun 30 '09 at 13:01
18

I am searching for the same thing, as are a lot of other people. Let's hope that django.contrib.search will be added soon.

In the meantime, this is what I found:

To me, most look quite complicated and, frankly, a little daunting to implement. I'd be interested to learn what you think of these.

Tim Cooper
  • 144,163
  • 35
  • 302
  • 261
davidhund
  • 311
  • 1
  • 4
9

The google code page for djangosearch indicates that it is no longer under active development, and suggests haystack or solango.

Joe Germuska
  • 1,508
  • 1
  • 17
  • 32
  • 2
    Solango says it is no longer under development and recommends the use of Haystack. – Rory Sep 12 '11 at 11:20
8

I'd recommend Sphinx for full-text search and aggregation, and django-sphinx is good enough for production use. We found that Sphinx was the least resource-intensive and fastest way to index and search our documents and that django-sphinx was a nice wrapper on top of the sphinx client.

The group by aggregation is particularly nice, if for example you want to display how many documents with a certain tag or by a certain author (or both) matched a search. In memory attribute updates were convenient too, especially for removing deleted articles immediately.

Joe W.
  • 1,062
  • 11
  • 8
6

Thanks Garth. I had seen that djangosearch wanted to become the official Django search, but I was hesitant to use it because I couldn't find any documentation! Luckily, there's a README in subversion that I hadn't seen before, and it makes the API look very cool:

# set up the model
class Event(models.Model):
    title = models.CharField(max_length=255)
    date = models.DateField()
    is_outdoors = models.BooleanField()

    index = djangosearch.ModelIndex(text=['title'], 
                                    additional=['date', 'is_outdoors'])

# run a search
results = Event.index.search("django conference")
Justin Voss
  • 6,084
  • 6
  • 32
  • 37
6

I just needed a very quick solution that was no-fuss for an internal app.

I found the article Adding search to Django in a snap, and that worked splendid for me!

Obviously it lacks the speed, scalability and features of the real projects like Haystack, but this one is easier to set up, and I don't really need anything else than keyword AND-search.

odinho - Velmont
  • 18,214
  • 6
  • 38
  • 30
3

You might want to consider letting Yahoo do all the hard work with their Build your own Search Service (BOSS). Here is a great blog post that walks you through the process: http://www.peterkrantz.com/2008/yahoo-search-in-django/

Gourneau
  • 11,760
  • 8
  • 41
  • 41
  • I've got a Django package that makes it even easier: https://bitbucket.org/jaap3/django-bosssearch/ – jaap3 May 13 '12 at 15:23
2

It looks like everyone here missed django-xappy

After quick evaluation of all existing search addons for Django, I found this one as most flexible and easiest to use. It's rough on the edges in few places, but it's still the best way to use power of Xapian search engine inside Django projects.

vvarp
  • 381
  • 2
  • 5
2

You might want to look at Django Solr search (aka "Solango") which comes with some nice documentation to get you started...

1

If you have large amount of data to be indexed or you expect high traffic, I'd suggest using some external search engine, like Solr. This way, you'll keep shared-nothing approach and be able to scale your site components independently.

zgoda
  • 12,351
  • 4
  • 35
  • 43
1

I think I am going to have to give a shout out to Djapian.

It is rock-solid...just pull down a source distribution and peek inside. Top notch code, not very many comments tho..

It's still a young software project, but I think the django community should throw it's weight behind this one.

0

If you are willing to use a 3rd party search engine I can recommend Yahoo BOSS and django-bosssearch.

Yahoo BOSS is a paid service, but it saves you setting up and maintaining other search software on your server.

jaap3
  • 2,204
  • 14
  • 31
0

Thanks Joe,

We decided to go with Tsearch2 and a custom postgres adaptor. Tsearch2 does not need an extra process to run, which was convenient since we are on a WebFaction hosting with limited memory... It's not completely done yet, but seems to be a good solution...

davidhund
  • 311
  • 1
  • 4
0

I found Djoosh which relies on the pure-python external search engine Whoosh to work well with my 'Python' brain.