为了快速总结,我们使用的是Elasticsearch 6.8.4,并且具有包含诸如“statutPublicOuInterne”(公共(public)或内部状态)或“identifiant”(标识符)之类的字段的文档。
出于安全原因(公司限制),我无法共享整个JSON(_source),但是它看起来像以下内容:
"_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",
(...)
}
一些“statutPublicOuInterne”可以具有诸如“enAttenteTraitementCommissionTask”或“enCoursTraitementCommissionTask”的值。第一个问题:,由于某种原因,当我搜索statutPublicOuInterne = enCoursTraitementCommissionTask时,它不起作用,但是如果我搜索statutPublicOuInterne = enCoursTraitementCommission(不带“任务”),它就可以工作!这对我来说似乎很奇怪,我真的无法解释。
第二个问题:如果我假设我需要在末尾没有“任务”的情况下进行搜索,则搜索statutPublicOuInterne = enCoursTraitementCommission可以,但是statutPublicOuInterne = enAttenteTraitementCommission无效! (statutPublicOuInterne = enAttenteTraitementCommissionTask也不起作用)
查询如下:
{
"query": {
"bool" : {
"must" : [
{
"match" : {
"statutPublicOuInterne" : {
"query" : "enAttenteTraitementCommission"
}
}
}
]
}
}
}
我只是不明白为什么它找不到任何东西,因为如果我使用“identifiant”字段来搜索此文档,那么它将起作用:{
"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",
(...)
}
}
]
}
}
我们可以在响应中清楚地看到“statutPublicOuInterne”:“enAttenteTraitementCommissionTask”。我想念什么吗?
在此先感谢您的帮助!
最佳答案
添加带有索引数据,映射,搜索查询和搜索结果的工作示例
索引映射:
{
"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"
}
}
]
关于elasticsearch - Elasticsearch查询显示奇怪的行为:错误?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/64700803/