ElasticSearch:使用输入字符串在多个字段中搜索(NumberFormatException)

时间:2015-07-23 19:19:24

标签: elasticsearch

我使用*星号表示法搜索查询中的多个字段(例如:我希望所有字段都以source开头,所以我指定字段source.*)并指定查询foobar的字符串。我使用Query String类型查询。

我一直收到NumberFormatException,并且我在其中有一些字段,其映射类型为longdouble

知道如何解决这个问题吗?我需要进行多字段搜索。

我的查询发布在下面:

{
    "query": {
        "bool": {
            "must": [{
                "query_string": {
                    "default_field": "source.*",
                    "query": "foobar"
                }
            }],
            "must_not": [],
            "should": []
        }
    },
    "from": 0,
    "size": 100000,
    "sort": [],
    "facets": {}
}

1 个答案:

答案 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