使用 JSON 请求 API 的嵌套 Solr 空间查询
Nested Solr spatial query using JSON request API
如何在 Apache Solr 中将嵌套查询与空间过滤器相结合?这是一个简化的嵌套查询,应该与空间过滤器结合使用:
curl "http://localhost:8983/solr/corename/query" -d '{
"query":{
"bool":{
"must":[
"type:product",
"product.siteid:(1.)",
]
}
}
}'
这样不行:
curl "http://localhost:8983/solr/corename/query" -d '{
"query":{
"bool":{
"must":[
"type:product",
"product.siteid:(1.)",
{
"filter":"{!bbox sfield=index.supplierloc}",
"pt":"52.5,10",
"d":"115"
}
]
}
}
}'
将空间过滤器与嵌套查询相结合的正确查询语法是什么?
注意:原始查询比较复杂,过滤器不能与“查询”处于同一级别,因为它需要是一个“必须”查询条件的一部分,但不能应用于另一个条件。
解决方法是:
"bbox":{
"sfield":"index.supplierloc",
"pt":"52.5,10",
"d":115
}
文档描述了如何将查询字符串转换为 JSON 对象的示例:
https://solr.apache.org/guide/8_0/json-query-dsl.html
最后,查询如下所示:
curl "http://localhost:8983/solr/aimeos/query" -d '{
"query":{
"bool":{
"must":[{
"bbox": {
"sfield":"index.supplierloc",
"pt":"52.5,10",
"d":"115"
}},
"type:product",
"product.siteid:(1.)"
]
}
}
}'
如何在 Apache Solr 中将嵌套查询与空间过滤器相结合?这是一个简化的嵌套查询,应该与空间过滤器结合使用:
curl "http://localhost:8983/solr/corename/query" -d '{
"query":{
"bool":{
"must":[
"type:product",
"product.siteid:(1.)",
]
}
}
}'
这样不行:
curl "http://localhost:8983/solr/corename/query" -d '{
"query":{
"bool":{
"must":[
"type:product",
"product.siteid:(1.)",
{
"filter":"{!bbox sfield=index.supplierloc}",
"pt":"52.5,10",
"d":"115"
}
]
}
}
}'
将空间过滤器与嵌套查询相结合的正确查询语法是什么?
注意:原始查询比较复杂,过滤器不能与“查询”处于同一级别,因为它需要是一个“必须”查询条件的一部分,但不能应用于另一个条件。
解决方法是:
"bbox":{
"sfield":"index.supplierloc",
"pt":"52.5,10",
"d":115
}
文档描述了如何将查询字符串转换为 JSON 对象的示例: https://solr.apache.org/guide/8_0/json-query-dsl.html
最后,查询如下所示:
curl "http://localhost:8983/solr/aimeos/query" -d '{
"query":{
"bool":{
"must":[{
"bbox": {
"sfield":"index.supplierloc",
"pt":"52.5,10",
"d":"115"
}},
"type:product",
"product.siteid:(1.)"
]
}
}
}'