2017-01-29 76 views
0

所有文本字段的文本索引我可以像使用此命令的mongodb紅寶石模型中的所有字段創建文本索引: db.documents.createIndex({ "$**": "text" }, { name: "TextIndex" })mongoid創建對模型

也可我們卻不知何故號屬性添加到索引。我已經試過這樣的,但它沒有

def fulltext_index 
    attributes.except(:_rev, :_type, :doc_type).values.map{|e| e.class==String ? e.to_s : ""}.join(" ").strip + " " + sequence.to_s 
end 

index({ fulltext_index: "text"}) 

回答