Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ApacheSolrJSON查询本地参数_Solr_Solrcloud - Fatal编程技术网

ApacheSolrJSON查询本地参数

ApacheSolrJSON查询本地参数,solr,solrcloud,Solr,Solrcloud,在Solr文档中,它重点解释了如何使用GET参数来定义查询,但对于如何使用更好的结构化JSON POST支持来完成相同的任务,它提供的信息很少。我找不到任何比表面解释更深入的文档 特别是,我试图在查询中使用本地参数,并想知道如何使用JSON POST而不是GET参数来完成以下操作: http://localhost:8983/solr/city/query?sort={!sfield=location pt=35.5514,-97.4075}geodist() asc&q={!geofi

在Solr文档中,它重点解释了如何使用GET参数来定义查询,但对于如何使用更好的结构化JSON POST支持来完成相同的任务,它提供的信息很少。我找不到任何比表面解释更深入的文档

特别是,我试图在查询中使用本地参数,并想知道如何使用JSON POST而不是GET参数来完成以下操作:

http://localhost:8983/solr/city/query?sort={!sfield=location pt=35.5514,-97.4075}geodist() asc&q={!geofilt sfield=location pt=35.5514,-97.4075 d=5}
根据您的查询,将映射到:

{
  "sort": "{!sfield=location pt=35.5514,-97.4075}geodist() asc",
  "query": "{!geofilt sfield=location pt=35.5514,-97.4075 d=5}"
}
根据您的查询,将映射到:

{
  "sort": "{!sfield=location pt=35.5514,-97.4075}geodist() asc",
  "query": "{!geofilt sfield=location pt=35.5514,-97.4075 d=5}"
}

为了完成@MatsLindh answer,您可以使用常用的参数名称,只要将它们包装在参数中,无需映射,例如:

file.json

{
  "params": {
    "q":"{!geofilt sfield=location pt=35.5514,-97.4075 d=5}",
    "sort":"{!sfield=location pt=35.5514,-97.4075}geodist() asc",
    "wt": "json",
    "indent": "true"
  }
}
使用curl的请求示例:

curl -H "Content-Type: application/json" -X "POST" --data @file.json http://localhost:8983/solr/city/query

为了完成@MatsLindh answer,您可以使用常用的参数名称,只要将它们包装在参数中,无需映射,例如:

file.json

{
  "params": {
    "q":"{!geofilt sfield=location pt=35.5514,-97.4075 d=5}",
    "sort":"{!sfield=location pt=35.5514,-97.4075}geodist() asc",
    "wt": "json",
    "indent": "true"
  }
}
使用curl的请求示例:

curl -H "Content-Type: application/json" -X "POST" --data @file.json http://localhost:8983/solr/city/query