未找到searchkick 400 [searchkick_search]

时间:2015-11-26 01:12:30

标签: ruby-on-rails ruby ruby-on-rails-3 searchkick

有人在使用searchkick遇到这种问题吗? 我做错事情了? 有人可以提示吗?

谢谢

控制器:

@products = Product.search(params[:query], page: params[:page])

模型:

after_touch :reindex

 searchkick mappings: {
    product: {
      properties: {
        name: {type: "string", analyzer: "keyword"}
      }
    }
  }
   def search_data
    as_json only: [:name, :price]
    # or equivalently
    {
      name: name,
      price: price
    }
   end
  

[400]   { “错误”:{ “ROOT_CAUSE”:[{ “类型”: “query_parsing_exception”, “理由”:“[比赛]   分析器[searchkick_search]没有   发现 “ ”索引“: ”products_development_20151125203817235“, ”线“:1, ”栏“:89}], ”类型“: ”search_phase_execution_exception“, ”理由“:” 所有   碎片   失败”, “相”: “查询”, “分组”:真 “failed_shards”:[{ “碎片”:0, “指数”: “products_development_20151125203817235”, “节点”: “f2jvKNboRcGf0NF11yEqyw”, “理由”:{ “类型”: “query_parsing_exception”, “理由”:“[比赛]   分析器[searchkick_search]没有   发现”, “索引”: “products_development_20151125203817235”, “线”:1, “栏”:89}}]}, “状态”:400}

1 个答案:

答案 0 :(得分:1)

merge_mappings变量设为true

after_touch :reindex

 searchkick merge_mappings: true, mappings: {
    product: {
      properties: {
        name: {type: "string", analyzer: "keyword"}
      }
    }
  }
   def search_data
    as_json only: [:name, :price]
    # or equivalently
    {
      name: name,
      price: price
    }
   end

然后运行rake searchkick:reindex:allModel.reindex

希望这会有所帮助。祝你好运!