Solr搜索服务的客户端
项目描述
solrpy
solrpy是Solr的Python客户端,Solr是一个基于Lucene的企业级搜索引擎。solrpy允许您将文档添加到Solr实例,然后使用Python对Solr执行查询并收集搜索结果。
概述
基本思路是这样的
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']
更强大的查询
查询、分面、高亮显示等可选参数可以作为Python参数传递给查询方法。您只需将点表示法(例如,facet.field)转换为下划线表示法(例如,facet_field),以便它们可以作为参数名称使用。
例如,假设您想获取搜索结果中的分面信息:
response = s.query('title:lucene', facet='true', facet_field='subject')
如果参数接受多个值,您只需将它们作为列表传递:
response = s.query('title:lucene', facet='true', facet_field=['subject', 'publisher'])
测试
要运行测试,您需要一个正在运行的Solr实例。最简单的方法是
curl -sSL https://raw.githubusercontent.com/moliware/travis-solr/master/travis-solr.sh | SOLR_VERSION=4.10.3 SOLR_CONFS=tests bash
社区
如果您有想法或建议,请随时加入我们的讨论列表。
关闭
solrpy-1.0.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | b1d009ace287782bf18d27e9f5b470ab6eb9d1e3e82ce0a63c94167d0b053e54 |
|
MD5 | 0cf70015aad710a11c04ea11e2242646 |
|
BLAKE2b-256 | 1f5072650922e21bcc0dd6afdb557db2c8a21e3061f1e4a1fe2d869638ba6755 |
关闭
solrpy-1.0.0-py3.6.egg的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 24bb803aa15efff0714967773580d15b8c6d7ad25a3fa3750d6bf7a4b9779ffa |
|
MD5 | fe843750bd1e757b8b2d4c923e5b5087 |
|
BLAKE2b-256 | 8d5f747196aba878fe83c8397eeeb6bb2452f44c46a31ac81471e5b0346119d7 |