我使用与mongoid轮胎(https://github.com/karmi/tire)。 这里是我的模型定义:
class SomethingWithTag
include Mongoid::Document
include Mongoid::Timestamps
field :tags_array, type: Array
include Tire::Model::Search
include Tire::Model::Callbacks
mapping do
indexes :tags_array, type: :array, index: :not_analyzed
end
end
说我有一个文件{tags_array:“世界你好”]}。 那么下面的查询做工精细:
SomethingWithTag.tire.search { filter :terms, :tags_array => ["hello"] }
SomethingWithTag.tire.search { filter :terms, :tags_array => ["world"] }
SomethingWithTag.tire.search { filter :terms, :tags_array => ["hello", "world"] }
但是,下列情况不返回任何结果:
SomethingWithTag.tire.search { filter :terms, :tags_array => ["hello world"] }
我应该怎么做才能使其工作?
编辑:下面是测试小块代码: http://pastebin.com/n1rUtK3e