通过列中的CURL-[globbing]坏范围执行Solr查询
我在Solr中有一个名为通过列中的CURL-[globbing]坏范围执行Solr查询,curl,solr,Curl,Solr,我在Solr中有一个名为test的核心。我已经摄取了其中的2个嵌套JSON文档。详情如下: {"id":1, "path":"1.parent", "_childDocuments_":{"path":"2.parent.child"}} 及 当我通过浏览器查询testcore以获得父子关系中的响应时,我更正了以下回答: http://localhost:8983/solr/test/select?fl=*,[child%20parentFilter=path:1.parent%20child
test
的核心。我已经摄取了其中的2个嵌套JSON文档。详情如下:
{"id":1, "path":"1.parent", "_childDocuments_":{"path":"2.parent.child"}}
及
当我通过浏览器查询test
core以获得父子关系中的响应时,我更正了以下回答:
http://localhost:8983/solr/test/select?fl=*,[child%20parentFilter=path:1.parent%20childFilter=path:2.parent.child]&indent=on&q={!parent%20which=%22path:1.parent%22}&wt=json
{
"responseHeader":{
"status":0,
"QTime":2,
"params":{
"q":"{!parent which=\"path:1.parent\"}",
"indent":"on",
"fl":"*,[child parentFilter=path:1.parent childFilter=path:2.parent.child]",
"wt":"json"}},
"response":{"numFound":2,"start":0,"docs":[
{
"id":"1",
"path":["1.parent"],
"_childDocuments_.path":["2.parent.child"],
"_version_":1565913168462479360},
{
"id":"2",
"path":["1.parent"],
"_childDocuments_.path":["2.parent.child"],
"_version_":1565913171789611008}]
}}
但当我尝试通过curl
运行相同的查询时,它显示错误:
$ curl 'http://localhost:8983/solr/test/select?fl=*,[child%20parentFilter=path:1.parent%20childFilter=path:2.parent.child]&indent=on&q={!parent%20which=%22path:1.parent%22}&wt=json'
curl: (3) [globbing] bad range in column 46
我无法理解via。虽然我可以理解
curl
请求在列46
上给出了错误,这是http
请求中的一个特殊字符[
。但是,它在浏览器中如何工作,我们如何通过curl
使此请求工作?只需传递curl参数-g/--globoff
当您设置
使用此选项,可以指定包含字母{}[]的URL
而不需要curl本身来解释它们。注意
这些字母不是正常的合法URL内容,但它们应该是根据URI标准进行编码。 另一方面,浏览器会自动转换字母
{}[]
,并成功提交查询
因此,您所要做的就是在提交之前使用curl参数或对查询字符串进行编码
我想这样应该行得通:
curl--globoff'http://localhost:8983/solr/test/select?fl=*,[child%20parentFilter=path:1.parent%20childFilter=path:2.parent.child]&indent=on&q={!parent%20which=%22path:1.parent%22}&wt=json'
太棒了。谢谢。
$ curl 'http://localhost:8983/solr/test/select?fl=*,[child%20parentFilter=path:1.parent%20childFilter=path:2.parent.child]&indent=on&q={!parent%20which=%22path:1.parent%22}&wt=json'
curl: (3) [globbing] bad range in column 46