显示奇怪行为的elasticsearch查询:bug?

f1tvaqid  于 2021-06-10  发布在  ElasticSearch
关注(0)|答案(1)|浏览(376)

为了快速总结,我们正在使用elasticsearch 6.8.4,文档中有“statutPublicuInterne”(公共或内部状态)或“identifier”(标识符)等字段。出于安全原因(公司限制),我无法共享整个json(\u源代码),但它看起来如下所示:

"_source": {
                    "dateCreation": "2020-11-05T16:31:28.404+01:00",
                    "dateDerModif": "2020-11-05T16:31:49.183+01:00",
                    "contenu": { ... }
                    "langue": "fr",
                    "observations": null,
                    "statutPublicOuInterne": "enAttenteTraitementCommissionTask",
                    "identifiant": "SFB-20201105-ELUH",
                    (...)
                }

一些“statutPublicuInterne”可以具有诸如“enattentetraitementcommissiontask”或“enourstraitementcommissiontask”之类的值。
第一个问题:由于某种原因,当我搜索statutpublicouinterne=encourstraitementcommissiontask时,它不起作用,但是如果我搜索statutpublicouinterne=encourstraitementcommissiontask(没有“task”),它就起作用了!这对我来说太奇怪了,我真的无法解释。
第二个问题:如果我假设我需要在结尾不带“任务”的情况下进行搜索,那么搜索statutpublicouinterne=enourstraitementcommission是可行的,但是statutpublicouinterne=enattentetraitementcommission不起作用(statutpublicouinterne=EnableAttentTraitementCommissionTask也不起作用)
查询如下:

{
    "query": {
        "bool" : {
            "must" : [
                {
                    "match" : {
                        "statutPublicOuInterne" : {
                            "query" : "enAttenteTraitementCommission"
                        }
                    }
                }
            ]
        }
    }
}

我只是不明白为什么它什么也找不到,因为如果我用它的“identifident”字段搜索这个文档,那么它就会工作:

{
    "query": {
        "bool" : {
            "must" : [
                {
                    "match" : {
                        "identifiant" : {
                            "query" : "SFB-20201105-ELUH"
                        }
                    }
                }
            ]
        }
    }
}

答案是:

{
    "took": 2,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": 1,
        "max_score": 2.0283146,
        "hits": [
            {
                "_index": "some-index",
                "_type": "demandes",
                "_id": "SFB-20201105-ELUH",
                "_score": 2.0283146,
                "_source": {
                    "dateCreation": "2020-11-05T16:31:28.404+01:00",
                    "dateDerModif": "2020-11-05T16:31:49.183+01:00",
                    "contenu": { ... }
                    "langue": "fr",
                    "observations": null,
                    "statutPublicOuInterne": "enAttenteTraitementCommissionTask",
                    "identifiant": "SFB-20201105-ELUH",
                    (...)
                }
            }
        ]
    }
}

我们可以在响应中清楚地看到“statutPublicuInterne”:“enattentetraitementcommissiontask”。
我错过什么了吗?
非常感谢您的帮助!

zzoitvuj

zzoitvuj1#

添加索引数据、Map、搜索查询和搜索结果的工作示例
索引Map:

{
  "mappings": {
    "properties": {
      "statutPublicOuInterne": {
        "type": "text"
      }
    }
  }
}

索引数据:

{
  "dateCreation": "2020-11-05T16:31:28.404+01:00",
  "dateDerModif": "2020-11-05T16:31:49.183+01:00",
  "langue": "fr",
  "observations": null,
  "statutPublicOuInterne": "enAttenteTraitementCommissionTask",
  "identifiant": "SFB-20201105-ELUH"
}

搜索查询:

{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "statutPublicOuInterne": {
              "query": "enAttenteTraitementCommissionTask"
            }
          }
        }
      ]
    }
  }
}

搜索结果:

"hits": [
      {
        "_index": "64700803",
        "_type": "_doc",
        "_id": "1",
        "_score": 0.2876821,
        "_source": {
          "dateCreation": "2020-11-05T16:31:28.404+01:00",
          "dateDerModif": "2020-11-05T16:31:49.183+01:00",
          "langue": "fr",
          "observations": null,
          "statutPublicOuInterne": "enAttenteTraitementCommissionTask",
          "identifiant": "SFB-20201105-ELUH"
        }
      }
    ]

相关问题