elasticsearch - 如何查看在 Elasticsearch 中被索引的分析令牌是什么
问题描述
给定一个源值“New-Value”,假设我有一个keyword
字段,我知道它被索引为“New-Value”不变,然后是一个text
字段,我知道它被索引为“new”,“value”两个小写标记. 现在对于一些带有一些自定义分析器的自定义字段,而不是自己仔细跟踪索引定义,是否有一种简单的方法可以查询从现有索引中索引的内容?
解决方案
您需要启用fielddata才能实现它,它未在text
字段上启用,之后您可以获得为 ES 倒排索引中的字段创建的令牌:
完整示例
索引映射
{
"mappings" :{
"properties" :{
"foo" :{
"type" : "text",
"fielddata": true
}
}
}
}
索引示例文档
{
"foo" : "Bar"
}
{
"foo" : "Bar and Baz"
}
并搜索查询以获取两个示例文档的倒排索引中的标记
{
"query": {
"match_all": {}
},
"docvalue_fields": [
{
"field": "foo"
}
]
}
结果
"hits": [
{
"_index": "myindex",
"_type": "_doc",
"_id": "1",
"_score": 1.0,
"_source": {
"foo": "Bar"
},
"fields": {
"foo": [
"bar"
]
}
},
{
"_index": "myindex",
"_type": "_doc",
"_id": "2",
"_score": 1.0,
"_source": {
"foo": "Bar and Baz"
},
"fields": {
"foo": [
"and",
"bar",
"baz"
]
}
}
]
推荐阅读
- c# - 如何检测方法自上次编译后是否已更改?
- visual-studio - Visual Studio Code 如何更改设置以不恢复旧会话,每次打开新窗口,新会话
- amazon-web-services - Application Load Balancer 的安全组
- mysql - 在mysql的过程中使用'NULL'
- curl - cURL 错误(curl: (18) 传输已关闭,剩余 349 个字节要读取)
- java - 在 Spark 中过滤 KeyValueGrouped 数据集
- python - Pyephem 和 pypredict/gpredict 的区别
- javascript - 为什么 JS Promise 的 async executor 和 async handler 方法表现不同?
- css - 根据祖父类更改伪元素样式
- ios - 没有为团队“XXX”找到具有 AppStore 连接访问权限的帐户