如何将 JSON 对象发送到 solr 集合 usinc cUrl
我正在使用 Windows 10。
curl -X POST -H "Content-Type:application/json" "http://localhost:8983/solr/solr_sample/update/json/docs" --data-binary "{'id': '1','title':'Doc 1'}"
当我使用这种格式时,我收到了某种警告消息:
curl -X POST -H 'Content-Type:application/json' 'http://localhost:8983/solr/sorl_sample/update/json/docs' --data-binary '{"id": "1","title":"Doc 1"}'
curl: (1) Protocol "'http" not supported or disabled in libcurl
curl: (3) [globbing] unmatched close brace/bracket in column 14
我解决了它使用“” insted ' '
当我使用第一个 url 发送请求时,我收到以下响应:
{
"responseHeader":{
"status":0,
"QTime":112}}
但是当我尝试通过搜索获得一些结果时,我在docs[]中看不到任何对象
curl -X GET "http://localhost:8983/solr/solr_sample/select?q=*:*"
结果:
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"*:*"}},
"response":{"numFound":0,"start":0,"docs":[]
}}
当我使用 Solr UI 时,我可以毫无问题地添加 JSON 对象,也可以在终端中查看结果
您必须提交更新。将 commit true 或 commitWithin 1000 添加到请求中,例如
curl -X POST -d '{"add":{"doc":{"id":"delete.me","title":"change.me"},"commitWithin":1000}}' -H "内容类型:application/json" http://localhost:8983/solr/solr_sample/update
也有效:
curl -X POST -d '{"add":{ "doc":{"id":"delete.me","title":"change.me"}}}' -H "Content-Type: application/ json" http://localhost:8983/solr/solr_sample/update?commit=true
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句