skip to navigation
skip to content

solar 0.2.19

A library to use solr in python projects.

Latest Version: 0.3.0

Library to use Solr with python.


  1. Searching:

    searcher = SolrSearcher() # you can't do real requests to Solr, use next: SolrSearcher('http://localhost:8180/db')
    q ='test', category=1).ps(5).qf('name^5 description').bf('linear(rank,100,0)')
  2. Filtering:

    q = q.filter(status=0).filter(category__in=[1, 2, 3]).exclude(rank__lte=5)
    q = q.exclude(rank=None)
  3. Grouping:

    q ='director', limit=5)
  4. Facets:

    q = q.facet('status').facet(['category', 'type'], params={'category': {'mincount': 5}})
    qf = q.get_query_filter()
    qf.add_ordering([(u'by rank', '-rank'), (u'by date', '-date_created')])
    # now you can filter your search query by get parameters
    # supports Django's QueryDict, webob's MultiDict or python dict
    q = qf.apply(q, {'status': [0,1], 'type': 3, 'type__gte': 5, 'sort': '-rank'})

There are facet.field and facet.query support. Also automatically adds tag for every fq and excludes corresponding fq’s from facets. See

  1. Mapping

Mapping docs and facets on any objects you want and then you can access it via .instance attribute:

class MovieSearcher(SolrSearcher):
    model = Movie

    # example of non-standart mapping
    class KeywordFacet(Facet):
        field = 'keywords'
        model = Keyword
        session = session

        def get_id(self, id):
            return id

        def get_instances(self, ids):
            return dict([(, obj) for obj in session.query(self.model).filter(])

    def get_instances(self, ids):
        return dict([(, obj) for obj in session.query(self.model).filter(])

q ='monty python').facet('keywords')
for doc in q:

for fv in q.results.get_facet('keywords'):
    print, fv.count
  1. Multiple Solr’s

Reading from and writing to multiple Solr instances. For reading choses Solr instance randomly. Writes into every Solr instance. You should syncronize reading Solr’s with writing instances manually (use rsync or something else).

  1. Lazy evaluate

Only iterating, count and access to .results attribute make http requests to Solr.


  • Dynamic fields support (need mapping for facets)
  • Groups refactoring
  • Lazy results and facets
  • and facet.range support
  • Django support
  • Documentation
  • Unit tests
File Type Py Version Uploaded on Size
solar-0.2.19.tar.gz (md5) Source 2013-05-16 32KB
  • Downloads (All Versions):
  • 16 downloads in the last day
  • 216 downloads in the last week
  • 915 downloads in the last month