opensearch-project / reporting

Export and automate PNG, PDF, and CSV reports in OpenSearch Dashboards
https://opensearch.org/docs/latest/dashboards/reporting/
Apache License 2.0
28 stars 64 forks source link

Searching with a PIT in a blank index returns the error 'field _id not found'" #984

Open miafgen opened 4 months ago

miafgen commented 4 months ago

Summary

Searching with a PIT in a blank index (which has never had a document) returns the error 'field _id not found'".

How can one reproduce the bug?

Steps to reproduce the behavior: 1. Create the index (PUT /dalisdata_buildings) REQUEST:

--EMPTY--

RESPONSE:

{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "dalisdata_buildings"
}

2. Request PIT (POST /dalisdata_buildings/_search/point_in_time?keep_alive=5m) REQUEST:

--EMPTY--

RESPONSE:

{
  "pit_id": "o7OBQQETZGFsaXNkYXRhX2J1aWxkaW5ncxZneVRBenB5MlFGT3UxdzFxZDQ0NjJBABZZU2FPUGtDSlFfQ3FTMjJkMEY3LXJBAAAAAAAAAAA9FlFKV05tVjgtVDlteXplazYzNEFnUEEBFmd5VEF6cHkyUUZPdTF3MXFkNDQ2MkEAAA==",
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "creation_time": 1711555893091
}

3. Run first search using PIT (GET /_search) <=== The bug manifests itself in this step REQUEST:

{
  "pit": {
    "id": "o7OBQQETZGFsaXNkYXRhX2J1aWxkaW5ncxZneVRBenB5MlFGT3UxdzFxZDQ0NjJBABZZU2FPUGtDSlFfQ3FTMjJkMEY3LXJBAAAAAAAAAAA9FlFKV05tVjgtVDlteXplazYzNEFnUEEBFmd5VEF6cHkyUUZPdTF3MXFkNDQ2MkEAAA=="
  },
  "slice": {
    "id": 0,
    "max": 2
  },
  "query": {
    "match_all": {}
  },
  "size": 10000
}

RESPONSE:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "field _id not found"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "dalisdata_buildings",
        "node": "YSaOPkCJQ_CqS22d0F7-rA",
        "reason": {
          "type": "illegal_argument_exception",
          "reason": "field _id not found"
        }
      }
    ],
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "field _id not found",
      "caused_by": {
        "type": "illegal_argument_exception",
        "reason": "field _id not found"
      }
    }
  },
  "status": 400
}

4. Add a document (PUT /dalisdata_buildings/_doc/foobar) REQUEST:

{
  "foo": "bar"
}

RESPONSE:

{
  "_index": "dalisdata_buildings",
  "_id": "foobar",
  "_version": 1,
  "result": "created",
  "_shards": {
    "total": 2,
    "successful": 1,
    "failed": 0
  },
  "_seq_no": 0,
  "_primary_term": 1
}

5. Remove the previously added document (DELETE /dalisdata_buildings/_doc/foobar) REQUEST:

--EMPTY--

RESPONSE:

{
  "_index": "dalisdata_buildings",
  "_id": "foobar",
  "_version": 2,
  "result": "deleted",
  "_shards": {
    "total": 2,
    "successful": 1,
    "failed": 0
  },
  "_seq_no": 1,
  "_primary_term": 1
}

6. Reexecute step 3 again (first search using PIT (GET /_search)) REQUEST:

{
  "pit": {
    "id": "o7OBQQETZGFsaXNkYXRhX2J1aWxkaW5ncxZneVRBenB5MlFGT3UxdzFxZDQ0NjJBABZZU2FPUGtDSlFfQ3FTMjJkMEY3LXJBAAAAAAAAAAA9FlFKV05tVjgtVDlteXplazYzNEFnUEEBFmd5VEF6cHkyUUZPdTF3MXFkNDQ2MkEAAA=="
  },
  "slice": {
    "id": 0,
    "max": 2
  },
  "query": {
    "match_all": {}
  },
  "size": 10000
}

RESPONSE:

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

What is the expected behavior? The expected response on step 3 is the one received in step 6, meaning:

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

What is your host/environment ?