3

誰かがサーチキックでこの種の問題を抱えていますか? 私は何か悪いことをした?誰かがヒントを惜しまない?

ありがとう

コントローラ:

@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":"[一致] アナライザー [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":"[一致] アナライザー [searchkick_search] が見つかりません", "索引":"products_development_20151125203817235","行":1,"列":89}}]},"ステータス":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:allか、Model.reindex

お役に立てれば。幸運を!

于 2015-11-26T01:32:57.390 に答える