Question

I am trying to run this command as part of my solr search:

with(:location).in_radius(x, y, 50, :bbox => true)

I have defined this in my model definition:

location :location do
  Sunspot::Util::Coordinates.new(latitude, longitude) if self.latitude
end

I can run this command:

with(:location).near(x, y, :precision => 3)

However, I can't run the in-radius search, which is what I really need.

Here is the server log:

  SOLR Request (5.0ms)  [ path=#<RSolr::Client:0x00000006fc4fa8> parameters={data: fq=type%3ADispenser&fq=%7B%21bbox+sfield%3Dlocation_s+pt%3D29.7601927%2C-95.36938959999999+d%3D50%7D&start=0&rows=10&q=%2A%3A%2A, method: post, params: {:wt=>:ruby}, query: wt=ruby, headers: {"Content-Type"=>"application/x-www-form-urlencoded; charset=UTF-8"}, path: select, uri: http://localhost:8982/solr/select?wt=ruby, open_timeout: , read_timeout: , retry_503: , retry_after_limit: } ]
Completed 500 Internal Server Error in 293.3ms

RSolr::Error::Http - RSolr::Error::Http - 500 Internal Server Error
Error:     The field location_s does not support spatial filtering

org.apache.solr.common.SolrException: The field location_s does not support spatial filtering
    at org.apache.solr.search.SpatialFilterQParser.parse(SpatialFilterQParser.java:86)
    at org.apache.solr.search.QParser.getQuery(QParser.java:142)
    at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:114)
    at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:173)
    at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
    at org.apache.solr.core.SolrCore.execute(SolrCore.java:1372)
    at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:356)
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:252)

Request Data: "fq=type%3ADispenser&fq=%7B%21bbox+sfield%3Dlocation_s+pt%3D29.7601927%2C-95.36938959999999+d%3D50%7D&start=0&rows=10&q=%2A%3A%2A"

--> Link to schema.xml <--

Was it helpful?

Solution

Based on what I can read from the Sunspot source, it appears that location fields do not support in_radius.

In the examples, all calls to in_radius use :coordinates_new. It seems that :coordinates_new is of type latlong instead of location.

Does using latlong instead of location solve your issue?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top