Rails Elasticsearch-模型模型映射 - raw和not_analyzed

时间:2015-04-07 23:41:53

标签: ruby-on-rails elasticsearch elasticsearch-model

我在我的应用程序中使用Elasticsearch-rails gem。我需要在模型中使用我的索引映射,使其看起来像您在下面看到的JSON(仅缩写为仅包含相关部分)。我不理解的部分与"名称有关。"如果这是我需要它的样子,那么如何设置该映射?

JSON映射我希望Rails模型输出

{  
   "recipes":{  
      "mappings":{  
         "list":{  
            "dynamic":"false",
            "properties":{  
               "creator_name":{  
                  "type":"string"
               },
               "name":{  
                  "type":"string",
                  "fields":{  
                     "raw":{  
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "permalink":{  
                  "type":"string"
               },
               "user_id":{  
                  "type":"string"
               }
            }
         }
      }
   }
}

当前Rails模型映射

  settings :index => { :number_of_shards => 1  } do
    mapping :dynamic => 'false' do
      indexes :user_id, :type => 'string'
      indexes :permalink, :type => 'string'
      indexes :creator_name, :type => 'string'
      indexes :name, :type => 'string' # How do i make this match the json?
    end
  end

如何设置' name'的索引?在模型中看起来像JSON?

非常感谢!

0 个答案:

没有答案