opensearch-project / opensearch-project/sql

[Bug] Support Multi-fields in WHERE Conditions

Open
#1,074 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

error-experience field types support PPL
Dominant language
Java
Stars
176
Forks
229
Avg merge
2d 21h
Merged PRs (30d)
43

Description

What is the bug?
There is limitation on Multi-fields in WHERE Conditions

If a field is defined with multiple types, then SQL engine treat it as text_keyword.

How can one reproduce the bug?
For example if the field defined as

"id1" : {
          "type" : "keyword",
          "fields" : {
            "id2" : {
              "type" : "integer"
            }
          }
        },

then following query

SELECT id1 
FROM sample_data 
WHERE n1 IN ('19') AND n2 IN ('299')
ORDER BY id1.id2 ASC LIMIT 10 OFFSET 0

will result in error

{
  "error": {
    "reason": "Invalid SQL query",
    "details": "can't resolve Symbol(namespace=FIELD_NAME, name=id1.id2) in type env",
    "type": "SemanticCheckException"
  },
  "status": 400
}

What is the expected behavior?
For multi-field (a text field with another keyword field inside), there should be no assumption that the keyword field name is always "keyword".

Query with above format should return expected result.

What is your host/environment?

  • OS: [e.g. iOS]
  • Version [e.g. 22]
  • Plugins

Do you have any screenshots?
If applicable, add screenshots to help explain your problem.

Do you have any additional context?
Add any other context about the problem.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with opensearch/src/main/java/org/opensearch/sql/opensearch/mapping/IndexMapping.java around the linked line, then review the multi-fields documentation and reproduce the query against the example mapping. Trace how the nested id1.id2 field is resolved and add coverage for a non-keyword multi-field. Done means the query returns the expected result without assuming the child field is named keyword.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.