【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
- iOS效能調優之Analyze靜態分析iOS
- elasticsearch Request Body 與 Query DSL詳解Elasticsearch
- Elasticsearch ILM DSL 索引生命週期管理Elasticsearch索引
- 【elasticsearch】搜尋過程詳解Elasticsearch
- knockout原始碼分析之執行過程原始碼
- Analyze分析表或者索引索引
- Spring原始碼分析之`BeanFactoryPostProcessor`呼叫過程Spring原始碼Bean
- 實踐007-elasticsearch查詢之2-Request Body與DSL查詢Elasticsearch
- 【Elasticsearch學習】文件搜尋全過程Elasticsearch
- 【Elasticsearch學習】DSL搜尋大全(持續更新中)Elasticsearch
- Elasticsearch(ES)的高階搜尋(DSL搜尋)(上篇)Elasticsearch
- Elasticsearch(ES)的高階搜尋(DSL搜尋)(下篇)Elasticsearch
- Elasticsearch查詢及聚合類DSL語句寶典Elasticsearch
- Elasticsearch Query DSL建立滾動索引(生命週期策略)Elasticsearch索引
- HDFS寫過程分析
- Windows啟動過程(MBR引導過程分析)Windows
- MySQL之mysqlcheck、check、optimize和analyzeMySql
- ANALYZE導致的阻塞問題分析
- dbms_stats與analyze分析彙總
- 資料需求分析過程
- 頁面渲染:過程分析
- ORACLE 死鎖分析過程Oracle
- Spark計算過程分析Spark
- Service啟動過程分析
- Activity啟動過程分析
- Kill會話過程分析會話
- sql執行過程分析SQL
- [原始碼分析] 訊息佇列 Kombu 之 啟動過程原始碼佇列
- Spring原始碼分析之Bean的建立過程詳解Spring原始碼Bean
- React Native Android 原始碼分析之啟動過程React NativeAndroid原始碼
- [個體軟體過程]之過程改進 (轉)
- 精盡MyBatis原始碼分析 - SQL執行過程(三)之 ResultSetHandlerMyBatis原始碼SQL
- 精盡MyBatis原始碼分析 - SQL執行過程(一)之 ExecutorMyBatis原始碼SQL
- 精盡MyBatis原始碼分析 - SQL執行過程(二)之 StatementHandlerMyBatis原始碼SQL
- Android 核心分析 之八------Android 啟動過程詳解Android