Search code examples
solrsolrjsolrcloud

solrj error executing query


I am trying to execute query

http://192.168.1.101:7070/solr/locationList_shard3_replica1/select?q=*:*&fq={!geofilt}&sfield=geometry&pt=19.7599,74.8091&d=50&sort=geodist()%20desc

It works perfectly with solr dashboard but when I tried from solrj error

My code is

query.addFilterQuery("{!geofilt}&sfield=geometry&pt="
                    + address.getGeometry() + "&d=1000000&sort=geodist() desc");

error missing sfield for spatial request


Solution

  • The string passed to addFilterQuery is the filter parameter. Just to be clear, the string you pass to the method addFilterQuery will be entirely encoded. Try to refactor the query in this way:

    query.add("fq", "{!geofilt}");
    query.add("sfield", "geometry");
    query.add("pt", address.getGeometry());
    query.add("sort", "geodist() desc");