Skip to main content

Client for the Solr search service

Project description

solrpy

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.

Overview

Here's the basic idea:

import solr

# create a connection to a solr server
s = solr.SolrConnection('http://example.org:8083/solr')

# 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'])

Tests

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

curl -sSL https://raw.githubusercontent.com/moliware/travis-solr/master/travis-solr.sh | SOLR_VERSION=4.10.3 SOLR_CONFS=tests bash

Community

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.

Source Distribution

solrpy-1.0.0.tar.gz (39.5 kB view details)

Uploaded Source

Built Distribution

solrpy-1.0.0-py3.6.egg (29.7 kB view details)

Uploaded Source

File details

Details for the file solrpy-1.0.0.tar.gz.

File metadata

  • Download URL: solrpy-1.0.0.tar.gz
  • Upload date:
  • Size: 39.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.4

File hashes

Hashes for solrpy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b1d009ace287782bf18d27e9f5b470ab6eb9d1e3e82ce0a63c94167d0b053e54
MD5 0cf70015aad710a11c04ea11e2242646
BLAKE2b-256 1f5072650922e21bcc0dd6afdb557db2c8a21e3061f1e4a1fe2d869638ba6755

See more details on using hashes here.

File details

Details for the file solrpy-1.0.0-py3.6.egg.

File metadata

  • Download URL: solrpy-1.0.0-py3.6.egg
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.4

File hashes

Hashes for solrpy-1.0.0-py3.6.egg
Algorithm Hash digest
SHA256 24bb803aa15efff0714967773580d15b8c6d7ad25a3fa3750d6bf7a4b9779ffa
MD5 fe843750bd1e757b8b2d4c923e5b5087
BLAKE2b-256 8d5f747196aba878fe83c8397eeeb6bb2452f44c46a31ac81471e5b0346119d7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page