I'm using elasticsearch with tire gem for Ruby on Rails.
so far so good, I have a successfull range facet on dates, but now i'm trying to do the same for a float field and it is giving me 'no parser for element' errors.
mapping
indexes :budget, type: 'float'
indexes :post_date, type: 'date'
end
(hiding the other fields)
in my search:
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
The timeline one works fine, I've re=indexed (force = true)
I get this error: (similar error repeated a few times)
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]]]
Relevant bit seems to be: Parse Failure [No parser for element [budget]]
No idea what is causing this, any input much appreciated!! thanks
I think you should reindex the index you want to use. For example, for Article class:
rake RAILS_ENV=production tire:import CLASS=Article FORCE=true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.