没有任何数据可供显示
| 开源项目社区 | 当前位置 : |
|
| www.trustie.net/open_source_projects | 主页 > 开源项目社区 > solrpy |
|
solrpy
|
| 2 | 0 | 49 |
| 贡献者 | 讨论 | 代码提交 |
概述
What is 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 your favorite programming language--python.
OverviewHere's the basic gist:
import solr
- create a connection to a solr server
s = solr.SolrConnection('http://example.org:8083/solr')
- add a document to the index
s.add(id=1, title='Lucene in Action', author=['Erik Hatcher', 'Otis Gospodnetić'])
s.commit()
- do a search
response = s.query('title:lucene')
for hit in response.results:
print hit['title']
Slightly More DetailsOptional 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 a parameter name.
For example, lets 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'])Installsolrpy is available at the pypi so you should be able to:solrpy@googlecode.com
easy_install solrpyOr you can check out the source code and:
python setup.py installDiscussFeel free to join our discussion list if you have ideas or suggestions. Also, please add examples to the wiki if you have the time and interest.
创建时间:2014-05-06 16:29
标签:
