通过CURL进行Solr查询-[globbing]列中的错误范围

him*_*ian 0 curl solr

我在Solr中有一个名为的核心test。我已经摄取了2个嵌套的JSON文档。它们如下:

{"id":1, "path":"1.parent", "_childDocuments_":{"path":"2.parent.child"}}
Run Code Online (Sandbox Code Playgroud)

{"id":2, "path":"1.parent", "_childDocuments_":{"path":"2.parent.child"}}
Run Code Online (Sandbox Code Playgroud)

当我test通过浏览器查询核心以寻求父子关系的响应时,我更正了回复:

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}]
  }}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试通过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
Run Code Online (Sandbox Code Playgroud)

我无法理解。虽然,我可以理解,curl请求给错误上column 46是一个特殊字符[http请求。但是,然后它如何在浏览器中工作,我们如何通过发出请求curl

fre*_*dev 6

只需传递以卷曲参数-g /-globoff

此选项关闭“ URL全局解析器”。设置此选项时,可以指定包含字母{} []的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'