【问题标题】:Sunspot SolrException: The field location_s does not support spatial filteringSunspot SolrException:字段 location_s 不支持空间过滤
【发布时间】:2014-04-18 05:30:05
【问题描述】:

我正在尝试将此命令作为我的 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"

--> Link to schema.xml

【问题讨论】:

  • 你能把location_s的定义贴在schema中吗?它通常需要是 LatLonType。
  • location_s 架构似乎不存在。只有位置,您可以尝试将字段重命名/复制到 location_s 以查看是否解决?不知道为什么太阳黑子将位置字段转换为 location_s。
  • 我看到这可能是重叠的 &lt;dynamicField name="*_s" stored="false" type="string" multiValued="false" indexed="true"/&gt; 可能会发生冲突,请尝试删除
  • 你能把整个模型课也发一下吗?

标签: ruby-on-rails solr lucene sunspot


【解决方案1】:

根据我从 Sunspot 源中可以看到的内容,location 字段似乎不支持 in_radius

在示例中,all calls to in_radius 使用 :coordinates_new。似乎是:coordinates_new is of type latlong 而不是location

使用latlong 代替location 能解决您的问题吗?

【讨论】:

  • 是的,这是 latlong 的事情.. 这也需要新版本的 sunspot / solr 才能正常工作。
猜你喜欢
  • 2015-03-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-07
  • 2021-06-19
  • 2015-01-09
  • 1970-01-01
相关资源
最近更新 更多