3

有人对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] {"error":{"root_cause":[{"type":"query_parsing_exception","re​​ason":"[match] 分析器 [searchkick_search] 未找到","index":"products_development_20151125203817235","line" :1,"col":89}],"type":"search_phase_execution_exception","re​​ason":"所有分片失败","phase":"query","grouped":true,"failed_shards":[{" shard":0,"index":"products_development_20151125203817235","node":"f2jvKNboRcGf0NF11yEqyw","re​​ason":{"type":"query_parsing_exception","re​​ason":"[match] 分析器 [searchkick_search] 未找到", “指数”:”products_development_20151125203817235","line":1,"col":89}}]},"status":400}

4

1 回答 1

2

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

希望这可以帮助。祝你好运!

于 2015-11-26T01:32:57.390 回答