【发布时间】:2018-05-18 03:21:21
【问题描述】:
我正在尝试学习 Elasticsearch,并且我正在使用 Kibana 来可视化事物。不过,我似乎无法弄清楚我的映射和查询出了什么问题。
我正在尝试存储照片元数据(iptc 数据)。我有以下映射:
{
"settings": {
"index": {
"analysis": {
"filter": {},
"analyzer": {
"keyword_analyzer": {
"filter": [
"lowercase",
"asciifolding",
"trim"
],
"char_filter": [],
"type": "custom",
"tokenizer": "keyword"
},
"edge_ngram_analyzer": {
"filter": [
"lowercase"
],
"tokenizer": "edge_ngram_tokenizer"
},
"edge_ngram_search_analyzer": {
"tokenizer": "lowercase"
}
},
"tokenizer": {
"edge_ngram_tokenizer": {
"type": "edge_ngram",
"min_gram": 2,
"max_gram": 5,
"token_chars": [
"letter"
]
}
}
}
}
},
"mappings": {
"doc": {
"properties": {
"photo_added": {
"type": "date",
"index": true,
"format": "yyyy-MM-dd' 'H:m:s"
},
"photo_id": {
"type": "long",
"index": true
},
"photo_owner": {
"type": "long",
"index": true
},
"project": {
"type": "long",
"index": true
},
"iptc": {
"type": "nested",
"properties": {
"caption/abstract": {
"type": "text",
"index": true
},
"copyright notice": {
"type": "text",
"index": true
},
"keywords": {
"type": "text",
"index": true,
"fields": {
"keywordstring": {
"type": "text",
"analyzer": "keyword_analyzer"
},
"edgengram": {
"type": "text",
"analyzer": "edge_ngram_analyzer",
"search_analyzer": "edge_ngram_search_analyzer"
},
"completion": {
"type": "completion"
},
"keyword": {
"type": "keyword"
}
}
},
"object name": {
"type": "text",
"index": true
},
"province/state": {
"type": "text",
"index": true
},
"sub-location": {
"type": "text",
"index": true
},
"time created": {
"type": "text",
"index": true
},
"urgency": {
"type": "text",
"index": true
},
"writer/editor": {
"type": "text",
"index": true
}
}
}
}
}
}
}
问题是:我想要一个通过关键字和标题搜索搜索文本是否存在的查询。每当在关键字中找到搜索文本时,分数就会提高,因为这表明照片具有更高的相关性。所以我制定了以下查询(其中 value 是搜索文本):
GET /photos/_search
{
"query": {
"dis_max": {
"queries": [
{
"fuzzy": {
"iptc.keywords": {
"value": "value",
"fuzziness": 1,
"boost": 1
}
}
},
{
"fuzzy": {
"iptc.caption/abstract": {
"value": "value",
"fuzziness": 1
}
}
}
]
}
}
}
然而,尽管值在文档中,但它似乎没有找到任何匹配项......而且我似乎无法构造一个简单的匹配查询来匹配确切的文本......例如:
GET /photos/doc/_search?error_trace=true
{
"query": {
"match": {
"iptc.caption/abstract": "exact value from one of the documents"
}
}
}
将返回 0 个结果...但是搜索文本恰好在文档中.. 我不知道该怎么做。更糟糕的是(对我来说,由于我的挫败感让我几乎秃顶了)Kibana 似乎采取了行动。我几乎可以肯定这是非常简单的事情(文档日期在 5 年内)但是当过滤精确的复制粘贴值它返回 0 结果...如屏幕截图所示...
我在这里疯了。有人知道如何解决这个问题或我做错了什么吗?
【问题讨论】:
-
请检查您的管理控制台窗口,那里的特定索引的映射有什么问题,或者尝试刷新它。
标签: elasticsearch kibana