https://github.com/search5/solrpy
Automatically exported from code.google.com/p/solrpy
https://github.com/search5/solrpy
Last synced: 4 months ago
JSON representation
Automatically exported from code.google.com/p/solrpy
- Host: GitHub
- URL: https://github.com/search5/solrpy
- Owner: search5
- License: other
- Created: 2015-03-13T08:12:26.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-10-20T21:38:57.000Z (about 5 years ago)
- Last Synced: 2024-05-22T01:18:36.808Z (over 1 year ago)
- Language: Python
- Size: 640 KB
- Stars: 39
- Watchers: 4
- Forks: 17
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-python - solrpy - Automatically exported from code.google.com/p/solrpy (Awesome Python / Search)
README
# solrpy
[](http://travis-ci.org/search5/solrpy)
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:
```python
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::
```python
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::
```python
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.
[Solr]: http://lucene.apache.org/solr/
[Lucene]: http://lucene.apache.org/java/docs/
[discussion list]: http://groups.google.com/group/solrpy