在弹性搜索中只有一个相同的查询成功执行?

only one of the identical query is executed successfully in elastic search?

您好,我在 docker 容器中有一个弹性搜索实例 运行ning。我有两个查询,每个查询都放在一个文件中,即 query6.json 和 query7.json。两个文件都包含相同的查询。

当我 运行 使用 curl 命令的查询之一时,它会提供结果。

curl -XGET http://localhost:55083/mep-reports*/_search?pretty -H "Content-Type: application/json" -d @query6.json 

上面查询的结果returns下面的结果

{
  "took": 10,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 100,
      "relation": "eq"
    },
    "max_score": null,
    "hits": [
      {
        "_index": "mep-reports",
        "_type": "_doc",
        "_id": "nMQ0N3wBcQytyR4tsuFr",
        "_score": null,
        "_source": {
          "inventory": "SMS",
          "msg_text": "This is random text",
          "status": "ENROUTE",
          "@timestamp": "2019-09-10T07:06:26.287Z",
          "o_error": "",
          "flight_id": "92348fa1-ca6c-456a-b3b2-85fba2d2deed",
          "recipient": "420736408281",
          "account_id": "a56f7e14-20f9-40e6-90c6-10604140ac5f",
          "sender": "8800111",
          "campaign_id": "6f2abca3-b46d-43f3-91be-3278a8dd7dc0",
          "nof_segments": 1,
          "@version": 1,
          "submission_ts": 1568105380000000,
          "delivery_ts": 1553616888000000,
          "campaign_name": "Starbucks Promotion",
          "flight_name": "Extremely very very long flight",
          "campaign_type": "NON_MARKETING",
          "created_by": "0c9d6015-f45f-4a90-a58c-8c99384aa40",
          "first_name": "Campaign",
          "last_name": "Manager"
        },
        "sort": [
          1568099186287
        ]
      },
      {
        "_index": "mep-reports",
        "_type": "_doc",
        "_id": "k8Q0N3wBcQytyR4tsuFr",
        "_score": null,
        "_source": {
          "inventory": "SMS",
          "msg_text": "This is random text",
          "status": "ENROUTE",
          "@timestamp": "2019-09-09T20:45:32.087Z",
          "o_error": "",
          "flight_id": "92348fa1-ca6c-456a-b3b2-85fba2d2deed",
          "recipient": "420736408283",
          "account_id": "a56f7e14-20f9-40e6-90c6-10604140ac5f",
          "sender": "8800111",
          "campaign_id": "6f2abca3-b46d-43f3-91be-3278a8dd7dc0",
          "nof_segments": 1,
          "@version": 1,
          "submission_ts": 1568105380000000,
          "delivery_ts": 1563144156000000,
          "campaign_name": "Starbucks Promotion",
          "flight_name": "Short Flight",
          "campaign_type": "NON_MARKETING",
          "created_by": "0c9d6015-f45f-4a90-a58c-8c99384aa40",
          "first_name": "Campaign",
          "last_name": "Manager"
        },
        "sort": [
          1568061932087
        ]
      }
    ]
  }
}

当我运行从第二个文件进行第二个查询时returns没有结果

 curl -XGET http://localhost:55083/mep-reports*/_search?pretty -H "Content-Type: application/json" -d @query7.json 

产出

{
  "took" : 4,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  }
}

我比较了一个工具中的文件,它们看起来是一样的。

我也做了 diff,结果如下。

diff query6.json query7.json 
47,50c47,53
<        {
<          "terms": {
<                "created_by": ["0c9d6015-f45f-4a90-a58c-8c99384aa40","0c9d6015-f45f-4a90-a58c-8c99384aa41"]           }
<        }
---
>         {
>           "terms": {
>             "created_by": [
>               "0c9d6015-f45f-4a90-a58c-08c99384aa40", "0c9d6015-f45f-4a90-a58c-08c99384aa41"
>             ]
>           }
>         }

这些文件的内容似乎完全相同。

请在此处查找文件

query6.json

{
  "from": 0,
  "size": 10,
  "timeout": "300s",
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "@timestamp": {
              "from": "2019-08-31T23:00:00.000Z",
              "to": null,
              "include_lower": true,
              "include_upper": true,
              "format": "yyyy-MM-dd'T'HH:mm:ss.SSSX",
              "boost": 1.0
            }
          }
        },
        {
          "range": {
            "@timestamp": {
              "from": null,
              "to": "2019-09-12T07:06:26.287Z",
              "include_lower": true,
              "include_upper": true,
              "format": "yyyy-MM-dd'T'HH:mm:ss.SSSX",
              "boost": 1.0
            }
          }
        },
        {
          "match": {
            "account_id": {
              "query": "a56f7e14-20f9-40e6-90c6-10604140ac5f",
              "operator": "OR",
              "prefix_length": 0,
              "max_expansions": 50,
              "fuzzy_transpositions": true,
              "lenient": false,
              "zero_terms_query": "NONE",
              "auto_generate_synonyms_phrase_query": true,
              "boost": 1.0
            }
          }
        },
       {
         "terms": {
               "created_by": ["0c9d6015-f45f-4a90-a58c-8c99384aa40","0c9d6015-f45f-4a90-a58c-8c99384aa41"]           }
       }
      ],
      "adjust_pure_negative": true,
      "boost": 1.0
    }
  },
  "sort": [
    {
      "@timestamp": {
        "order": "desc"
      }
    }
  ]
}

query7.json

{
  "from": 0,
  "size": 10,
  "timeout": "300s",
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "@timestamp": {
              "from": "2019-08-31T23:00:00.000Z",
              "to": null,
              "include_lower": true,
              "include_upper": true,
              "format": "yyyy-MM-dd'T'HH:mm:ss.SSSX",
              "boost": 1.0
            }
          }
        },
        {
          "range": {
            "@timestamp": {
              "from": null,
              "to": "2019-09-12T07:06:26.287Z",
              "include_lower": true,
              "include_upper": true,
              "format": "yyyy-MM-dd'T'HH:mm:ss.SSSX",
              "boost": 1.0
            }
          }
        },
        {
          "match": {
            "account_id": {
              "query": "a56f7e14-20f9-40e6-90c6-10604140ac5f",
              "operator": "OR",
              "prefix_length": 0,
              "max_expansions": 50,
              "fuzzy_transpositions": true,
              "lenient": false,
              "zero_terms_query": "NONE",
              "auto_generate_synonyms_phrase_query": true,
              "boost": 1.0
            }
          }
        },
        {
          "terms": {
            "created_by": [
              "0c9d6015-f45f-4a90-a58c-08c99384aa40", "0c9d6015-f45f-4a90-a58c-08c99384aa41"
            ]
          }
        }
      ],
      "adjust_pure_negative": true,
      "boost": 1.0
    }
  },
  "sort": [
    {
      "@timestamp": {
        "order": "desc"
      }
    }
  ]
}

如果您能提供帮助,我们将不胜感激 谢谢

这里有区别:

{
   "terms":{
      "created_by":[
         "0c9d6015-f45f-4a90-a58c-8c99384aa40",
         "0c9d6015-f45f-4a90-a58c-8c99384aa41"
      ]
   }
}

{
   "terms":{
      "created_by":[
         "0c9d6015-f45f-4a90-a58c-08c99384aa40",
         "0c9d6015-f45f-4a90-a58c-08c99384aa41"
      ]
   }
}

额外 0 个字符。