如何设置轮胎弹性搜索的默认分析仪?

编程入门 行业动态 更新时间:2024-10-27 23:25:09
本文介绍了如何设置轮胎弹性搜索的默认分析仪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 最近我一直在使用ruby在rails上进行弹性搜索。我无法获取我的数据索引,所以我可以搜索具有复数和非复数关键字的项目。

轮胎将允许我为每个映射属性分配一个分析器:

映射do 索引标题,分析器:'snowball'索引体,分析器:'snowball ' end

现在,说我的标题为'tests' / p>

如果我使用查询中的属性进行搜索: http:// localhost:9200 / myindex / mymapping / _search?q = title:test 它将工作。

但是,如果我没有指定如下属性进行常规搜索: http:// localhost:9200 / myindex / mymapping / _search?q = test

它不会找到文档。

如何指定我想要默认分析器为雪球,所以我不必指定属性I想搜索?

p.s。我正在使用轮胎宝石。所以请尽可能最好地回答这个问题。

解决方案

可以使用索引设置更改默认分析器: p>

require'rubygems' require'tire' 轮胎.index'articles'do delete create:settings => {:index => {:analysis => {:analyzer => {:default => {:type => 'snowball'} } } } },:mappings => {:article => {:properties => {:title => {:type => 'string',:analyzer => 'snowball'},:body => {:type => 'string',:analyzer => 'snowball'} } } } store:title => 'Tests',:body => 多元 store:title => 'Test',:body => 单数 刷新结束

I have been experimenting with elasticsearch lately with ruby on rails. I am having trouble getting my data indexed so I can search for items with both plural, and non-plural keywords.

Tire will allow me to assign an analyzer per mapping attribute:

mapping do indexes title, analyzer: 'snowball' indexes body, analyzer: 'snowball' end

Now, say I have a keyword in the title of 'tests'

if I do a search with the attribute in the query: localhost:9200/myindex/mymapping/_search?q=title:test It will work.

However, if I do a general search without specifying the attribute like so: localhost:9200/myindex/mymapping/_search?q=test

It will not find the document.

How do I specify that I want the default analyzer to be 'snowball' so I don't have to specify the attribute I want to search on?

p.s. I am using the Tire Gem. So please answer as best as you can taking that into account.

解决方案

It's possible to change default analyzer using index settings:

require 'rubygems' require 'tire' Tire.index 'articles' do delete create :settings => { :index => { :analysis => { :analyzer => { :default => { :type => 'snowball' } } } } }, :mappings => { :article => { :properties => { :title => { :type => 'string', :analyzer => 'snowball'}, :body => { :type => 'string', :analyzer => 'snowball'} } } } store :title => 'Tests', :body => "Plural" store :title => 'Test', :body => "Singular" refresh end

更多推荐

如何设置轮胎弹性搜索的默认分析仪?

本文发布于:2023-08-07 19:39:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1321358.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:分析仪   轮胎   弹性   如何设置

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!