Json 必须匹配返回大量文档的URL地址-Elasticsearch
我只是想检查有多少文档具有相同的Json 必须匹配返回大量文档的URL地址-Elasticsearch,json,
elasticsearch,Json,
elasticsearch,我只是想检查有多少文档具有相同的link值。发生了一些奇怪的事情 假设一个或多个文档具有此链接值:https://twitter.com/someUser/status/1288024417990144000 我使用以下JSON查询搜索它: /theIndex/_doc/_search { "query": { "bool": { "must": [ {
link
值。发生了一些奇怪的事情
假设一个或多个文档具有此
链接
值:https://twitter.com/someUser/status/1288024417990144000
我使用以下JSON查询搜索它:
/theIndex/_doc/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"link": "https://twitter.com/someUser/status/1288024417990144000"
}
}
]
}
}
}
它返回546中的522个文档,第一个文档是正确的文档。它的作用更像一个查询字符串
,而不是必须匹配的字符串
如果我搜索另一个更独特的字段,如sha256sum
:
{
"query": {
"bool": {
"must": [
{
"match": {
"sha256sum": "dad06b7a0a68a0eb879eaea6e4024ac7f97e38e6ac2b191afa7c363948270303"
}
}
]
}
}
}
它返回1个文档,就像它应该返回的一样
我也尝试过搜索must-term
,但它返回0个文档
映射 我不认为这么简单的问题会这么难解决。我只是在眼前错过了什么吗
有人知道这里可能发生了什么吗?即使我没有看到映射中的
链接
字段(是源代码
?),我怀疑它是一个文本
字段,文本字段也会被分析。如果要执行精确匹配,需要在link.keyword
字段中进行匹配,它的行为将与您期望的一样:
{
"query": {
"bool": {
"must": [
{
"match": {
"link.keyword": "https://twitter.com/someUser/status/1288024417990144000"
^
|
add this
}
}
]
}
}
}
您的
链接
字段的映射是什么?它现在包含在您的mapping@Val这是我的错。我现在修好了。啊,好的,我明白了。我错过了.关键字。非常感谢你!
{
"query": {
"bool": {
"must": [
{
"match": {
"link.keyword": "https://twitter.com/someUser/status/1288024417990144000"
^
|
add this
}
}
]
}
}
}