Search code examples
solrsolrcloud

Apache Solr JSON Querying Local Params


In the Solr documentation it focuses explanations on how to use the GET parameters to define queries, but gives very little information on how to accomplish the same tasks using the better structured JSON POST support. I have been unable to find any documentation that goes deeper than very surface-level explanation.

Particularly, I'm trying to utilize local params in my queries and would like to know how to accomplish the following using a JSON POST instead of GET params:

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}

Solution

  • According to JSON Request API / Parameters Mapping your query would map to:

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