【发布时间】:2015-10-14 09:23:17
【问题描述】:
我正在使用 python 函数将数据索引到本地主机上的 solr 我的代码如下
import urllib
import urllib2
def indexSolrVenue():
url = 'http://localhost:8983/solr/venue/update/json?commit=true&wt=json'
data = '[{"id":"3","title":"allen"}]'
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
print the_page
在 solr 中,我定义了一个接受 id 和标题的模式。我尝试使用 postman chrome 扩展将数据发送到 url
http://localhost:8983/solr/venue/update/json?commit=true
有数据
[{'id':'2','title':'test1'}]
它被正确索引并反映在 solr 中。但是如果我在终端上运行 python 代码,我会得到以下输出
{"responseHeader":{"status":0,"QTime":6}}
这实际上意味着当我尝试使用 : query
搜索数据时,数据正在被索引但在 solr 上http://localhost:8983/solr/venue/select?q=*%3A*&wt=json&indent=true
它没有显示 id:3 记录。
我在我的代码中做错了吗?请帮忙 提前谢谢
【问题讨论】: