弹性搜索:边缘数字和数字 [英] ElasticSearch: EdgeNgrams and Numbers

查看:88
本文介绍了弹性搜索:边缘数字和数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于EdgeNgram如何处理数字的任何想法?



我正在使用ElasticSearch后端运行haystack。我创建了一个类型为EdgeNgram的索引字段。该字段将包含一个可能包含单词和数字的字符串。



当我使用部分单词对该字段进行搜索时,它的工作原理如何。但是,如果我输入了一个部分号码,我没有得到我想要的结果。



示例:



我通过键入edgen来搜索索引字段EdgeNgram 12323,我会得到返回给我的索引。如果我通过键入123搜索相同的索引,我什么也没有。



想法?

解决方案

如果您正在使用edgeNGram tokenizer,那么它会将EdgeNGram 12323视为单个令牌,然后在其上应用edgeNGraming进程。例如,如果min_grams = 1 max_grams = 4,您将得到以下索引的令牌:[E,Ed,Edg,Edge]。所以我想这不是你真正寻找的 - 考虑使用edgeNGram令牌过滤器:



如果你使用edgeNGram令牌过滤器,确保你'使用一个实际上标记文本EdgeNGram 12323以产生两个令牌的标记器:[EdgeNGram,12323](标准或空白标记器将会做到这一点)。一般来说,edgeNGram将采用12323并产生诸如1,12,123的标记等等...


Any ideas on how EdgeNgram treats numbers?

I'm running haystack with an ElasticSearch backend. I created an indexed field of type EdgeNgram. This field will contain a string that may contain words as well as numbers.

When I run a search against this field using a partial word, it works how it's supposed to. But if I put in a partial number, I'm not getting the result that I want.

Example:

I search for the indexed field "EdgeNgram 12323" by typing "edgen" and I'll get the index returned to me. If I search for that same index by typing "123" I get nothing.

Thoughts?

解决方案

if you're using the edgeNGram tokenizer, then it will treat "EdgeNGram 12323" as a single token and then apply the edgeNGram'ing process on it. For example, if min_grams=1 max_grams=4, you'll get the following tokens indexed: ["E", "Ed", "Edg", "Edge"]. So I guess this is not what you're really looking for - consider using the edgeNGram token filter instead:

If you're using the edgeNGram token filter, make sure you're using a tokenizer that actually tokenizes the text "EdgeNGram 12323" to produce two tokens out of it: ["EdgeNGram", "12323"] (standard or whitespace tokenizer will do the trick). Then apply the edgeNGram filter next to it.

In general, edgeNGram will take "12323" and produce tokens such as "1", "12", "123", etc...

这篇关于弹性搜索:边缘数字和数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆