2014-03-03 48 views
0

我使用的輪胎寶石Elasticsearch融入我的應用程序,但它拋出一個錯誤,當我嘗試我的命名範圍適用於它:如何將指定範圍應用於輪胎搜索結果?

scope :unflagged, -> { where('flags_count < 4') } 


def self.search(params) 
    tire.search(page: params[:page], per_page: 12) do 
     query { string params[:query], default_operator: "AND" } if params[:query].present? 
    sort { by :unflagged } if params[:query].blank? 
    end 
end 

錯誤:

400 : {"error":"SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[JDdrV2g5RWiePD6SezSHvQ][posts][1]: SearchParseException[[posts][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"sort\":[\"unflagged\"],\"size\":12}]]]; nested: SearchParseException[[posts][1]: from[-1],size[-1]: Parse Failure [No mapping found for [unflagged] in order to sort on]]; }{[JDdrV2g5RWiePD6SezSHvQ][posts][2]: SearchParseException[[posts][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"sort\":[\"unflagged\"],\"size\":12}]]]; nested: SearchParseException[[posts][2]: from[-1],size[-1]: Parse Failure [No mapping found for [unflagged] in order to sort on]]; }{[JDdrV2g5RWiePD6SezSHvQ][posts][0]: SearchParseException[[posts][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"sort\":[\"unflagged\"],\"size\":12}]]]; nested: SearchParseException[[posts][0]: from[-1],size[-1]: Parse Failure [No mapping found for [unflagged] in order to sort on]]; }{[JDdrV2g5RWiePD6SezSHvQ][posts][4]: SearchParseException[[posts][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"sort\":[\"unflagged\"],\"size\":12}]]]; nested: SearchParseException[[posts][4]: from[-1],size[-1]: Parse Failure [No mapping found for [unflagged] in order to sort on]]; }{[JDdrV2g5RWiePD6SezSHvQ][posts][3]: SearchParseException[[posts][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"sort\":[\"unflagged\"],\"size\":12}]]]; nested: SearchParseException[[posts][3]: from[-1],size[-1]: Parse Failure [No mapping found for [unflagged] in order to sort on]]; }]","status":400} 

我我發現在SO上發佈了幾個類似的問題,但從來沒有回答過。

任何人都可以解釋是否有可能將命名的作用域應用於Tire/Elasticsearch?如果是這樣,怎麼樣?

回答

0

我不確定這是否符合「答案」的要求,但是完全被困住了,看到有幾個類似的關於範圍和輪胎的未解答的問題,我會推薦其他人有相同的問題來簡單地使用另一個搜索客戶。

我的標準是它在Heroku上有一個免費的層次生產支持,相對容易實現,具有良好的文檔,並支持我現有的範圍。

我已經用Swiftype,符合所有這些標準,在heroku上提供出色的documentation,樣本appfree tier