Elasticsearch- 分词查询

查看分词的命令, ES配置完成后需要测试分词,看看分词是否达到预期效果。 

curl 命令查看:

1. 使用自定义的分析器查看分词:ansj_index_synonym:自定交分析器名称.  pretty :json格式显示

 

[plain]  view plain copy 在CODE上查看代码片 派生到我的代码片
 
  1. curl -XGET 'http://localhost:8200/zh/_analyze?analyzer=ansj_index_synonym&pretty' -d '童装童鞋'  

 

 

2. 使用自定义的分词器(tokenizer)和过滤器(filters)查看分词:

 

[plain]  view plain copy 在CODE上查看代码片 派生到我的代码片
 
  1. curl -XGET 'http://localhost:8200/zh/_analyze?tokenizer=ansj_index&filters=synonym&pretty' -d '童装童鞋'  

 

 

3. 查询某个字段的分词:

 

[plain]  view plain copy 在CODE上查看代码片 派生到我的代码片
 
  1. curl -XGET 'http://localhost:8200/zh/_analyze?field=brand_name&pretty' -d '童装童鞋'  

 

 

“brand_name”:字段名称,如果是字段是nest,object类型,也可以写成"brand_name. name"

 

除了自定义自己的分析器,ES自己也有内置分析器如:

standard 
simple 
whitespace 
stop 
keyword 
pattern 
language
snowball 
custom

具体解释:http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-standard-analyzer.html  

需要英文好点在同鞋。 

 

ES还内置了分词器和过滤器:

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-tokenizers.htmlstandard
edge_ngram
keyword
letter
lowercase
ngram 
whitespace 
pattern 
uax_email_url 
path_hierarchy 
ascii folding 
length 
lowercase 
uppercase 
nGram 
edge_ngram 
porter_stem 
shingle 
stop 
word_delimiter 
stemmer 
stemmer_override 
keyword_marker 
keyword_repeat 
kstem 
snowball 
phonetic 
synonym 
reverse 
elision 
truncate 
unique 
pattern_capture 
pattern_replace 
trim 
limit
hunspell 
common_grams 
normalization 
delimited_payload 
keep_words 

elasticsearch-analysis-mmseg

https://github.com/medcl/elasticsearch-analysis-mmseg
基于 http://code.google.com/p/mmseg4j/

elasticsearch-analysis-jieba

https://github.com/huaban/elasticsearch-analysis-jieba

elasticsearch-analysis-ansj

https://github.com/4onni/elasticsearch-analysis-ansj

elasticsearch-analysis-ik

https://github.com/medcl/elasticsearch-analysis-ik

elasticsearch-analysis-paoding

https://github.com/medcl/elasticsearch-analysis-paoding

 

中文分词推荐用ik,mmseg,这两个分词器有更新。

ansj,paoding分词器很久没更新了,没有对应比较高的es版本。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值