Search code examples
pythondjangodjango-search-lucene

Can I use Django 1.1 with django-search-lucene for full-text searching, and if so, what resources/links/docs can I reference to get it up and running?


A little background:

  • I want to use Django Search with Lucene
  • I have Django 1.1 w/ Python 2.5 installed
  • MySQL 5.1 is being used
  • My local machine is running Windows Vista x64, but we will deploy to Red Hat Linux
  • Yes, I wish that right about now I was running Linux.

Solution

  • I would recommend Apache SOLR, which is built on top of Lucene. The primary advantage is that it exposes an easy to use API, and can return a native Python object. Here is an example of how to call it from Python:

    params = urllib.urlencode({        
        "rows": "100",       
        "fl": "id,name,score,address,city,state,zip",        
        "wt": "python",        
        "q": "+name:Foo +city:Boston"
    })        
    
    request = urllib2.urlopen(urllib2.Request("http://locahost:8983/solr/select", params))
    response = ast.literal_eval(request.read())
    request.close()            
    return response["docs"]