0

我正在将 elasticsearch 与轮胎宝石一起用于 Ruby on Rails。

到目前为止一切顺利,我在日期上有一个成功的范围方面,但现在我正在尝试对浮点字段做同样的事情,它给了我“没有元素解析器”错误。

mapping
  indexes :budget, type: 'float'
  indexes :post_date, type: 'date'
end

(隐藏其他字段)

在我的搜索中:

tire.search(load: true, page: params[:page], per_page: 8) do
  query do
    boolean do
      must { string params[:query], default_operator: "AND" } if params[:query].present?
    end
    facet('timeline') { range :post_date, { :ranges => [ { to: Date.today+1, from: Date.today-7 }, { to: Date.today+1, from: Date.today-14 }, { to: Date.today+1, from: Date.today-30 } ] } } 
    facet('budget') { range :budget, {:ranges => [{ to: 500 }, { from: 500, to: 1000 },{ from: 1000, to: 1500 },{ from: 1500 }]}}
  end
end

时间线工作正常,我已重新编制索引(力 = 真)

我收到此错误:(类似错误重复了几次)

500 : {"error":"SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[8B30I3dRQ6elhGcF6El0lw][projects][1]: SearchParseException[[projects][1]: query[(status:posted status:awarded status:closed)~1],from[-1],size[-1],sort[<custom:\"display_type\": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@618faee9>!,<custom:\"post_date\": org.elasticsearch.index.field.data.longs.LongFieldDataType$1@6e9691da>]: Parse Failure [Failed to parse source [{\"query\":{\"bool\":{\"must\":[{\"terms\":{\"status\":[\"posted\",\"awarded\",\"closed\"]}}]}},\"sort\":[{\"display_type\":\"desc\"},\"post_date\"],\"facets\":{\"status\":{\"terms\":{\"field\":\"status\",\"size\":10,\"all_terms\":false}},\"industry_finance\":{\"terms\":{\"field\":\"finance\",\"size\":10,\"all_terms\":false}},\"industry_law\":{\"terms\":{\"field\":\"law\",\"size\":10,\"all_terms\":false}},\"industry_consulting\":{\"terms\":{\"field\":\"consulting\",\"size\":10,\"all_terms\":false}},\"expertise\":{\"terms\":{\"field\":\"expertise\",\"size\":25,\"all_terms\":false}},\"skills\":{\"terms\":{\"field\":\"skills\",\"size\":25,\"all_terms\":false}},\"country\":{\"terms\":{\"field\":\"geo\",\"size\":10,\"all_terms\":false}},\"language\":{\"terms\":{\"field\":\"language\",\"size\":10,\"all_terms\":false}},\"location\":{\"terms\":{\"field\":\"location\",\"size\":10,\"all_terms\":false}},\"timeline\":{\"range\":{\"field\":\"post_date\",\"ranges\":{\"ranges\":[{\"to\":\"2012-12-09\",\"from\":\"2012-12-01\"},{\"to\":\"2012-12-09\",\"from\":\"2012-11-24\"},{\"to\":\"2012-12-09\",\"from\":\"2012-11-08\"}]}}},\"budget\":{\"range\":{\"field\":\"budget\",\"ranges\":{\"ranges\":[{\"to\":500},{\"from\":500,\"to\":1000},{\"from\":1000,\"to\":1500},{\"from\":1500}]}}}},\"size\":8}]]]; nested: SearchParseException[[projects][1]: query[(status:posted status:awarded status:closed)~1],from[-1],size[-1],sort[<custom:\"display_type\": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@618faee9>!,<custom:\"post_date\": org.elasticsearch.index.field.data.longs.LongFieldDataType$1@6e9691da>]: Parse Failure [No parser for element [budget]]]

相关位似乎是:解析失败[元素[预算]没有解析器]
不知道是什么原因造成的,非常感谢任何输入!谢谢

4

1 回答 1

0

我认为您应该重新索引要使用的索引。例如,对于文章类:

耙 RAILS_ENV=生产轮胎:进口 CLASS=Article FORCE=true

于 2013-02-15T11:51:26.737 回答