exact valuehtml
2017-01-01,exact value,搜索的時候,必須輸入2017-01-01,才能搜索出來
若是你輸入一個01,是搜索不出來的app
full text測試
例如:spa
就不是說單純的只是匹配完整的一個值,而是能夠對值進行拆分詞語後(分詞)進行匹配,也能夠經過縮寫、時態、大小寫、同義詞等進行匹配code
doc1:I konw my mom likes small dogs.orm
doc2:His mom likes dogs, so do I.htm
分詞,初步創建倒排索引:索引
Word | doc1 | doc2 |
---|---|---|
I | √ | √ |
konw | √ | |
my | √ | |
mom | √ | √ |
likes | √ | √ |
small | √ | |
dogs | √ | √ |
His | √ | |
so | √ | |
do | √ |
若是咱們想搜索 mother like little dog
, 是不會有任何結果的。token
這不是咱們想要的結果,爲在咱們看來,mother和mom有區別嗎?同義詞,都是媽媽的意思。like和liked有區別嗎?沒有,都是喜歡的意思,只不過一個是如今時,一個是過去時。little和small有區別嗎?同義詞,都是小小的。dog和dogs有區別嗎?狗,只不過一個是單數,一個是複數。ip
實際上,es在創建倒排索引的時候進行了 normalization 操做,對拆分出的各個單詞進行相應的處理,以提高後面搜索的時候可以搜索到相關聯的文檔的機率。
好比,時態的轉換,單複數的轉換,同義詞的轉換,大小寫的轉換。
切分詞語
進行 normalization(提示recall召回率)
給你一段句子,而後將這段句子拆分紅一個一個的單個的單詞,同時對每一個單詞進行normalization(時態轉換,單複數轉換)。
recall 即召回率,就是在搜索的時候,增長可以搜索到的結果的數量。
分析器包含三部分:
Set the shape to semi-transparent by calling set_trans(5)
standard analyzer s
set, the, shape, to, semi, transparent, by, calling, set_trans, 5(默認的是standard)
simple analyzer
set, the, shape, to, semi, transparent, by, calling, set, trans
whitespace analyzer
Set, the, shape, to, semi-transparent, by, calling, set_trans(5)
language analyzer(特定的語言的分詞器,好比說,english,英語分詞器)
set, shape, semi, transpar, call, set_tran, 5
語法:
1GET /_analyze
2{
3 "analyzer": "standard",
4 "text": "Text to analyze"
5}
6返回:
7{
8 "tokens": [
9 {
10 "token": "text",
11 "start_offset": 0,
12 "end_offset": 4,
13 "type": "<ALPHANUM>",
14 "position": 0
15 },
16 {
17 "token": "to",
18 "start_offset": 5,
19 "end_offset": 7,
20 "type": "<ALPHANUM>",
21 "position": 1
22 },
23 {
24 "token": "analyze",
25 "start_offset": 8,
26 "end_offset": 15,
27 "type": "<ALPHANUM>",
28 "position": 2
29 }
30 ]
31}
複製代碼