[英]Index field on embedded documents with tire gem for ElasticSearch?
如何使用Tire gem为ElasticSearch的语法索引嵌入式文档中的特定字段?
我已经为嵌入许多答案的Question模型尝试了以下内容,并且我只希望对Answer模型上的描述字段建立索引。
搜索与存储的答案说明匹配的文本不会返回任何结果。 顺便说一下,我正在使用Mongoid作为MongoDB驱动程序。
mapping do
indexes :id, :index => :no
indexes :created_at, :index => :no
indexes :updated_at, :index => :no
indexes :title, :index => :analyzed
indexes :description, :index => :analyzed
indexes :page_views, :index => :no
indexes :asker, :index => :no
indexes :tags, :index => :analyzed
indexes :answers do
indexes :id, :index => :no
indexes :description, :index => :analyzed
indexes :answerer, :index => :no
indexes :created_at, :index => :no
indexes :updated_at, :index => :no
end
indexes :comments, :index => :no
indexes :votes, :index => :no
indexes :up_count, :index => :no
indexes :down_count, :index => :no
indexes :vote_score, :index => :no
end
我认为您需要先指定每个字段的类型,然后才能设置“ index”参数。 (我可能错了)
我认为这行不通:
"properties": {
"description": {
"index": "analyzed"
}
}
尝试以下方法:
"properties": {
"description": {
"type": "string",
"index": "analyzed" //not really needed as the default is analyzed
}
}
您能否使用以下方法检查您的映射:
curl -XGET 'http://localhost:9200/your_index/your_type/_mapping'
发布输出,我们将查看elasticsearch是否正确配置。
祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.