以下 python 代码添加了一个文档,但没有 json 内容:
solr_instance = pysolr.Solr('http://192.168.45.153:8983/solr/test', timeout=60)
json_filename = '/path/to/file/test.json'
argws = {
'commit': 'true',
'extractOnly': False,
'Content-Type': 'application/json',
}
with open(json_filename, 'rb') as f:
solr_instance.extract(f, **argws)
solr_instance.commit()
curl
从命令行使用按预期工作:
$ curl 'http://192.168.45.153:8983/solr/test/update?commit=true' \
--data-binary @/path/to/file/test.json \
-H 'Content-Type: application/json'
该文件有以下内容:
$ cat /cygdrive/w/mist/test.json
--> [{"x": "a","y": "b"}]
我正在使用pysolr 3.6.0
和solr 6.5.0