[英]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.