测试代码1:

def test(self):
data = {"add": {"doc": {"id": "100001", "*字段名*": u"我是一个大好人"}}}
params = {"boost": 1.0, "overwrite": "true", "commitWithin": 1000}
url = 'http://127.0.0.1:8983/solr/mycore/update?wt=json'
headers = {"Content-Type": "application/json"}
r = requests.post(url, json=data, params=params, headers=headers)
print r.text
def Index_data(self):
solr = pysolr.Solr('http://127.0.0.1:8983/solr/mycore/', timeout=10)
# How you'd index data.
result = solr.add([
{
"id": "doc_1",
"title": "A test document",
},
{
"id": "doc_2",
"title": "The Banana: Tasty or Dangerous?",
},
])
print result