You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by Aimeos | Norbert Sendetzky <no...@aimeos.com> on 2021/11/12 12:17:43 UTC

Nested Solr spatial query using JSON request API

Hi there

How to combine a nested query with a spatial filter in Apache Solr? This
is a simplified nested query which should be combined with a spatial filter:

curl "http://localhost:8983/solr/corename/query" -d '{
  "query":{
    "bool":{
      "must":[
        "type:product",
        "product.siteid:(1.)",
      ]
    }
  }
}'

It doesn't work this way:

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"
        }
      ]
    }
  }
}'

What's the correct query syntax to combine spatial filters with nested
queries?

Note: The original query is more complex and the filter can't be at the
same level as "query" because it needs to be part of one "must" query
conditions but must not be applied to another condition.

Cheers
Tom