【DSL】Elasticsearch之Analyze(分析過程)
_analyze是Elasticsearch一個非常有用的API,它可以幫助你分析每一個field或者某個analyzer/tokenizer是如何分析和索引一段文字。
返回結果欄位含義:
token是一個實際被儲存在索引中的詞
position指明詞在原文字中是第幾個出現的
start_offset和end_offset表示詞在原文字中佔據的位置。
1、預設analyzer
GET /_analyze?
{"analyzer" : "standard", "text" : "床前明月光"}
{
"tokens": [
{
"token": "床",
"start_offset": 0,
"end_offset": 1,
"type": "<IDEOGRAPHIC>",
"position": 0
},
{
"token": "前",
"start_offset": 1,
"end_offset": 2,
"type": "<IDEOGRAPHIC>",
"position": 1
},
{
"token": "明",
"start_offset": 2,
"end_offset": 3,
"type": "<IDEOGRAPHIC>",
"position": 2
},
{
"token": "月",
"start_offset": 3,
"end_offset": 4,
"type": "<IDEOGRAPHIC>",
"position": 3
},
{
"token": "光",
"start_offset": 4,
"end_offset": 5,
"type": "<IDEOGRAPHIC>",
"position": 4
}
]
}
2、也可以用指定的analyzer來分析使用whitspace
GET /_analyze?
{
"analyzer" : "whitespace",
"text" : "床前 明月光"
}
{
"tokens": [
{
"token": "床前",
"start_offset": 0,
"end_offset": 2,
"type": "word",
"position": 0
},
{
"token": "明月光",
"start_offset": 3,
"end_offset": 6,
"type": "word",
"position": 1
}
]
}
3、使用ik分析器
GET /tystock/_analyze?
{
"analyzer": "ik_max_word",
"text" : "床前明月光"
}
{
"tokens": [
{
"token": "床前明月光",
"start_offset": 0,
"end_offset": 5,
"type": "CN_WORD",
"position": 0
},
{
"token": "床前",
"start_offset": 0,
"end_offset": 2,
"type": "CN_WORD",
"position": 1
},
{
"token": "明月光",
"start_offset": 2,
"end_offset": 5,
"type": "CN_WORD",
"position": 2
},
{
"token": "明月",
"start_offset": 2,
"end_offset": 4,
"type": "CN_WORD",
"position": 3
},
{
"token": "明",
"start_offset": 2,
"end_offset": 3,
"type": "CN_WORD",
"position": 4
},
{
"token": "月光",
"start_offset": 3,
"end_offset": 5,
"type": "CN_WORD",
"position": 5
},
{
"token": "月",
"start_offset": 3,
"end_offset": 4,
"type": "CN_WORD",
"position": 6
},
{
"token": "光",
"start_offset": 4,
"end_offset": 5,
"type": "CN_CHAR",
"position": 7
}
]
}
4、使用拼音分析器
GET /tystock/_analyze?
{
"analyzer": "pinyin",
"text" : "床前明月光"
}
{
"tokens": [
{
"token": "chuang",
"start_offset": 0,
"end_offset": 1,
"type": "word",
"position": 0
},
{
"token": "cqmyg",
"start_offset": 0,
"end_offset": 5,
"type": "word",
"position": 0
},
{
"token": "qian",
"start_offset": 1,
"end_offset": 2,
"type": "word",
"position": 1
},
{
"token": "ming",
"start_offset": 2,
"end_offset": 3,
"type": "word",
"position": 2
},
{
"token": "yue",
"start_offset": 3,
"end_offset": 4,
"type": "word",
"position": 3
},
{
"token": "guang",
"start_offset": 4,
"end_offset": 5,
"type": "word",
"position": 4
}
]
}
---------------------
懶得整理,直接粘來留存一下
作者:飛飛好奇
來源:CSDN
原文:https://blog.csdn.net/xf_87/article/details/79402489
相關文章
- ElasticSearch DSL 查詢Elasticsearch
- 教你快速從SQL過度到Elasticsearch的DSL查詢SQLElasticsearch
- Elasticsearch Query DSL查詢入門Elasticsearch
- Elasticsearch ILM DSL 索引生命週期管理Elasticsearch索引
- elasticsearch Request Body 與 Query DSL詳解Elasticsearch
- 【elasticsearch】搜尋過程詳解Elasticsearch
- Spring原始碼分析之`BeanFactoryPostProcessor`呼叫過程Spring原始碼Bean
- 實踐007-elasticsearch查詢之2-Request Body與DSL查詢Elasticsearch
- 【Elasticsearch學習】文件搜尋全過程Elasticsearch
- React Native Android 原始碼分析之啟動過程React NativeAndroid原始碼
- ANALYZE導致的阻塞問題分析
- 【Elasticsearch學習】DSL搜尋大全(持續更新中)Elasticsearch
- Elasticsearch Query DSL建立滾動索引(生命週期策略)Elasticsearch索引
- Elasticsearch查詢及聚合類DSL語句寶典Elasticsearch
- Elasticsearch(ES)的高階搜尋(DSL搜尋)(上篇)Elasticsearch
- Elasticsearch(ES)的高階搜尋(DSL搜尋)(下篇)Elasticsearch
- HDFS寫過程分析
- Spring原始碼分析之Bean的建立過程詳解Spring原始碼Bean
- 頁面渲染:過程分析
- Linux 啟動過程分析Linux
- Liferay 啟動過程分析
- 資料需求分析過程
- flink:JobGraph生成過程分析
- [原始碼分析] 訊息佇列 Kombu 之 啟動過程原始碼佇列
- 精盡MyBatis原始碼分析 - SQL執行過程(一)之 ExecutorMyBatis原始碼SQL
- 精盡MyBatis原始碼分析 - SQL執行過程(二)之 StatementHandlerMyBatis原始碼SQL
- 精盡MyBatis原始碼分析 - SQL執行過程(三)之 ResultSetHandlerMyBatis原始碼SQL
- 主機被入侵分析過程
- Spring Security 啟動過程分析Spring
- openGauss核心:SQL解析過程分析SQL
- Eureka Server啟動過程分析Server
- 隨機過程(高斯隨機過程、譜分析、白噪聲)隨機
- MySQL之儲存過程MySql儲存過程
- 死磕 java集合之TreeMap原始碼分析(二)- 內含紅黑樹分析全過程Java原始碼
- 死磕 java集合之TreeMap原始碼分析(三)- 內含紅黑樹分析全過程Java原始碼
- 死磕 java集合之TreeMap原始碼分析(一)- 內含紅黑樹分析全過程Java原始碼
- MYSQL 連線登入過程分析MySql
- JavaScript的預編譯過程分析JavaScript編譯