[英]indexing data to solr update url from python code in json format does not update the record in solr
我正在使用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和title的模式。 我嘗試使用郵遞員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記錄。
我在代碼中做錯了嗎? 請提前幫助thanx
req.add_header('Content-type', 'application/json')
您需要為req對象中的內容設置標題。 請在調用urllib2.urlopen(req)
之前使用以上語句;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.