Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

Client for the Solr search service

Project description


Build Status

solrpy is a Python client for Solr, an enterprise search server built on top of Lucene. solrpy allows you to add documents to a Solr instance, and then to perform queries and gather search results from Solr using Python.


Here's the basic idea:

import solr

# create a connection to a solr server
s = solr.SolrConnection('')

# add a document to the index
doc = {
  "id": 1,
  "title": "Lucene in Action",
  "author": ["Erik Hatcher", "Otis Gospodnetić"]
s.add(doc, commit=True)

# do a search
response = s.query('title:lucene')
for hit in response.results:
    print hit['title']

More powerful queries

Optional parameters for query, faceting, highlighting and more like this can be passed in as Python parameters to the query method. You just need to convert the dot notation (e.g. facet.field) to underscore notation (e.g. facet_field) so that they can be used as parameter names.

For example, let's say you wanted to get faceting information in your search result::

response = s.query('title:lucene', facet='true', facet_field='subject')

and if the parameter takes multiple values you just pass them in as a list::

response = s.query('title:lucene', facet='true', facet_field=['subject', 'publisher'])


To run the tests, you need to have a running solr instance. The easiest way to do this is:

curl -sSL | SOLR_VERSION=4.10.3 SOLR_CONFS=tests bash


Feel free to join our discussion list if you have ideas or suggestions.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
solrpy-0.9.9-py3-none-any.whl (14.7 kB) Copy SHA256 hash SHA256 Wheel py3
solrpy-0.9.9.tar.gz (76.7 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page