[英]Setting up a MoreLikeThis Query using Tire/ElasticSearch
I am using Tire/ElasticSearch to index models in my rails application. 我正在使用Tire / ElasticSearch在我的Rails应用程序中索引模型。
I am trying to set up a very simple more_like_this query as follows on the index "articles"/field content 我正在尝试在索引“文章” /字段内容上建立一个非常简单的more_like_this查询,如下所示
s = Tire.search 'articles' do
query do
mlt_field do
content { string 'electricity' }
end
end
end
When I run this I get this error 当我运行这个我得到这个错误
undefined method `mlt_field' for #<Tire::Search::Query:0x000001013657e8 @value={}>
Does anybody have any insight how I can set this up? 有人对我如何进行设置有任何见解吗? I have looked through the very good Tire documentation but I can't see any help for this. 我浏览了很好的Tyre文档,但看不到任何帮助。 I found a similar query fuzzy_like_this and Github issues says to search for fuzzy in the README but I can't find any reference to this. 我发现了类似的查询Fuzzy_like_this和Github问题说要在自述文件中搜索模糊,但是我找不到对此的任何引用。
In the end I resorted to using the direct query syntax, which didn't seem to throw any error. 最后,我求助于使用直接查询语法,该语法似乎没有引发任何错误。
s1 = Tire.search 'articles', :query =>
{ :mlt_field =>
{ :content =>
{ :like_text => 'electricity',
:min_term_freq => 1,
:analyzer => :mlt_content
}
}
}
I think this failed because More Like This support is in tire-contrib , a separate optional gem from Tire core. 我认为此操作失败了,因为“更多类似”支持位于tire-contrib中 ,这是Tire核心中的一个单独的可选宝石。
mlt_field
is defined here in tire-contrib . mlt_field
是在tire-contrib中定义的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.