Hi all,

For Google's Summer of Code last year, I worked on djangosearch 
(http://code.google.com/p/djangosearch/ 
) with the aim of extending it with more backends. It soon became  
clear that the full text support in Django's database backends was  
sufficient for most small sites. Considering the "__search" field  
lookup already exists, I have since been working on better built in  
support:

http://github.com/bfirsh/django/tree/search

This includes support for PostgreSQL in addition to MySQL,  searching  
across multiple fields, automatic index creation, relevance, admin  
full text search and a simple generic search view. A brief example of  
the API:

class Article(models.Model):
    headline = models.CharField(max_length=100, search_index=True,  
search_weight=1)
    pub_date = models.DateTimeField()
    body = models.TextField(search_index=True, search_weight=0.3)

    class Meta:
        ordering = ('pub_date', 'headline')

    def __unicode__(self):
        return self.headline

 >>> Article.objects.search('alpha')
[<Article: Django 1.1 alpha 1 released>, <Article: Django 1.1 beta  
released>]

 >>> Article.objects.search('beta')
[<Article: Django 1.1 alpha 1 released>, <Article: Django 1.1 beta  
released>]

 >>> Article.objects.search('beta').order_by('-search__relevance')
[<Article: Django 1.1 beta released>, <Article: Django 1.1 alpha 1  
released>]

 >>> Article.objects.filter(body__search='prague')
[<Article: EuroDjangoCon 2009>]

Feedback would be gratefully appreciated. In particular, the  
search__relevance field is being hacked into the select at the moment,  
and there is no relevance for the __search filter. It could either be  
added automatically, or we could possibly use something like  
annotate(Relevance('body', 'prague')). Ideas welcome.

Also, if anybody's interested in adding support for SQLite and Oracle,  
let me know.

Of course, external engines such as Solr, Xapian, Whoosh and Sphinx  
still need support. Daniel Lindsley has recently released a fantastic  
search app based on djangosearch called Haystack (http://haystacksearch.org/ 
). There are some very smart guys working on new backends, so if you  
have any interest in external search engines for Django, I would  
encourage you to get involved!

http://groups.google.com/group/django-haystack/

I will be at EuroDjangocon, so maybe we should hold a discussion of  
some sort if anyone is interested. Search is an area that has been  
disorganised for a while; new users have no idea where to start.

Ben


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to