Skip to content

Fix alias type referring to nested field#3674

Merged
penghuo merged 1 commit intoopensearch-project:mainfrom
qianheng-aws:fixAlias
May 27, 2025
Merged

Fix alias type referring to nested field#3674
penghuo merged 1 commit intoopensearch-project:mainfrom
qianheng-aws:fixAlias

Conversation

@qianheng-aws
Copy link
Copy Markdown
Collaborator

@qianheng-aws qianheng-aws commented May 26, 2025

Description

Fix the bugs related to alias type, which includes:

  • Support alias type whose path points to a nested field, see details in issue: [BUG] Field of Alias type in PPL does not work as expected #3646

  • For Calcite engine, make push down projects with the original path of alias type instead of alias name itself.
    For the example in above issue, it will return hits with empty source content if pushing down using alias name,

POST /test/_search
{
   "query": {
     "term": {
        "log.url.message.keyword": {"value": "/e2e/h/zap"}
     }
   },
   "_source": ["message_alias"]
}

-----
{
  "took": 14,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": 1.0,
    "hits": [
      {
        "_index": "test",
        "_id": "o3DjC5cBzm8WW6d_tOff",
        "_score": 1.0,
        "_source": {}
      }
    ]
  }
}
  • For both v2 and calcite engine, when pushing down filter with alias type field whose original fields is text type, we need to use its original field's keyword. Otherwise, it will return no hits.
    Still using above index for example, it will return no hits when using DSL:
POST /test/_search
{
   "query": {
     "term": {
        "message_alias.keyword": {"value": "/e2e/h/zap"}
     }
   }
}

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

But it could return the correct results if using its original fields:

POST /test/_search
{
   "query": {
     "term": {
        "log.url.message.keyword": {"value": "/e2e/h/zap"}
     }
   }
}

-----
{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": 1.0,
    "hits": [
      {
        "_index": "test",
        "_id": "o3DjC5cBzm8WW6d_tOff",
        "_score": 1.0,
        "_source": {
          "log": {
            "url": {
              "message": "/e2e/h/zap",
              "time": 1
            }
          }
        }
      }
    ]
  }
}

However, for alias field points to non-text type field, it could work using alias field in the filter directly:

POST /test/_search

{
   "query": {
     "term": {
        "time_alias": {"value": 1}
     }
   }
}
----
{
  "took": 15,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": 1.0,
    "hits": [
      {
        "_index": "test",
        "_id": "o3DjC5cBzm8WW6d_tOff",
        "_score": 1.0,
        "_source": {
          "log": {
            "url": {
              "message": "/e2e/h/zap",
              "time": 1
            }
          }
        }
      }
    ]
  }
}

Related Issues

Resolves #3646

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Heng Qian <qianheng@amazon.com>
@qianheng-aws qianheng-aws changed the title Fix alias type points to nested field Fix alias type referring to nested field May 27, 2025
@qianheng-aws qianheng-aws added calcite calcite migration releated bug Something isn't working labels May 27, 2025
@LantaoJin
Copy link
Copy Markdown
Member

For the case of alias type field whose original fields is text type, it seems a bug of OpenSearch Core.

@penghuo penghuo merged commit 68cdbab into opensearch-project:main May 27, 2025
23 checks passed
penghuo pushed a commit that referenced this pull request Jun 16, 2025
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
@qianheng-aws qianheng-aws deleted the fixAlias branch March 26, 2026 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working calcite calcite migration releated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Field of Alias type in PPL does not work as expected

3 participants