takezoe / solr-scala-client

Solr Client for Scala
Apache License 2.0
91 stars 43 forks source link

Missing spatial parameters while building solr query #63

Closed palak21 closed 4 years ago

palak21 commented 4 years ago

We are building a solr query using this library. we want to add couple of spatial fields namely sname and pt How do you add spatial parameters to the query builder image

takezoe commented 4 years ago

Currently, this library doesn't support spatial parameters but adding them is a good idea.

palak21 commented 4 years ago

is it possible to amend the URL on the fly and add the spatial parameters till the time we have support for the same?

Ukjain commented 4 years ago

Hey, It seems SolrQuery class does not have an option to set Spatial parameters. Do you have idea of how we can achieve this? https://lucene.apache.org/solr/6_6_0/solr-solrj/org/apache/solr/client/solrj/SolrQuery.html

takezoe commented 4 years ago

According to this thread: https://lucene.472066.n3.nabble.com/Spatial-search-with-SolrJ-3-1-How-to-td2961136.html, we can achive as follows:

solrQuery.setQuery("*:*");
solrQuery.addFilterQuery("{!func}geodist()");
solrQuery.set("sfield", "store");
solrQuery.set("pt", lat + "," + lon);
solrQuery.set("sort", "geodist() asc"); 
Ukjain commented 4 years ago

Yup i did same thing and i have added this to your lib have raised pull request please check.

takezoe commented 4 years ago

Oh, thanks! Let me see.

takezoe commented 4 years ago

Added spatial parameters support in #64.