我正在尝试将此命令作为我的solr搜索的一部分运行:
with(:location).in_radius(x, y, 50, :bbox => true)
我已经在我的模型定义中定义了这个:
location :location do
Sunspot::Util::Coordinates.new(latitude, longitude) if self.latitude
end
我可以运行此命令:
with(:location).near(x, y, :precision => 3)
然而,我无法进行半径内搜索,这是我真正需要的。
这是服务器日志:
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"
- &GT; Link to schema.xml&lt; -
答案 0 :(得分:1)
根据我从太阳黑子来源中读到的内容,location
字段似乎不支持in_radius
。
在示例中,all calls to in_radius
使用:coordinates_new
。似乎是:coordinates_new
is of type latlong
而不是location
。
使用latlong
代替location
是否可以解决您的问题?