簡體   English   中英

模型中定義的Rails Elasticsearch分析器映射未在Elasticsearch中報告

[英]Rails Elasticsearch analyzer mappings defined in model are not reported in elasticsearch

在我的食譜模型中,我有:

class Recipe < ActiveRecord::Base

index_name "recipes-#{Rails.env}"

settings do
  mappings dynamic: 'false' do
    indexes :title, type: 'string', analyzer: 'french'
    indexes :description, type: 'string', analyzer: 'french'
  end
end

def as_indexed_json(options={})
  self.as_json({only: [:title, :description]})
end

然后在Rails控制台中,啟動Recipe.import 通過curl或Sense GET /recipes-development/_mapping/ ,我得到了

{
   "recipes-development": {
      "mappings": {
         "recipe": {
            "properties": {
               "description": {
                  "type": "string"
               },
               "title": {
                  "type": "string"
               }
            }
         }
      }
   }
}

我丟失了有關分析儀的所有信息。 任何想法將不勝感激

Recipe.import之前,您必須執行

Recipe.__elasticsearch__.create_index! force: true

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM