2012-04-12 66 views
0

我使用mongoid搜索來搜索人們上傳的圖像的標題和說明。我也想搜索一組標籤,因爲人們給這些圖片標籤。我正在使用gem mongoid_taggable創建標籤,該標籤存儲在一個數組中,我使用mongoid_search來搜索數組。使用mongoid搜索搜索標籤數組

mongoid_search索引一切,但標籤,我不知道如何使它索引標籤數組。

search_in :title, :tags, :description, :designer => :name, :designer => :username 

field :width 
field :height 
field :description, :type => String 
field :title, :type => String 
field :tags, type: Array 

任何想法?

+0

我建議發佈到項目的問題:https://github.com/mauriciozaffari/mongoid_search/issues – 2012-04-13 15:41:27

+0

你認爲這是一個問題在寶石?這不是我在這裏做錯了嗎?你知道它是如何在其他標籤和搜索相關的寶石。難以找到答案? – 2012-04-15 13:29:57

回答

0

我發現了。 mongoid_taggable在數據庫中創建了一個tags_array,所以我需要執行search_in:tags_array而不是search_in:tags。