我使用*
星号表示法搜索查询中的多个字段(例如:我希望所有字段都以source
开头,所以我指定字段source.*
)并指定查询foobar
的字符串。我使用Query String
类型查询。
我一直收到NumberFormatException
,并且我在其中有一些字段,其映射类型为long
和double
。
知道如何解决这个问题吗?我需要进行多字段搜索。
我的查询发布在下面:
{
"query": {
"bool": {
"must": [{
"query_string": {
"default_field": "source.*",
"query": "foobar"
}
}],
"must_not": [],
"should": []
}
},
"from": 0,
"size": 100000,
"sort": [],
"facets": {}
}
答案 0 :(得分:5)
将lenient设置为 true 以忽略基于格式的失败
示例:
class ProductsController < ApplicationController
def new
@product = Product.new
end
def edit
@product = Product.find(params[:id])
end
def update
@product = Product.find(params[:id])
if @product.update(product_params)
flash[:success] = "Updated Succesfully!"
render 'home/index'
else
render 'shared/modal' #this is the same modal as a partial..
end
end
private
def product_params
params.require(:product).permit(:title, :asin)
end
end