Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Support search for non-keyword fields for text #1887

Open
Yury-Fridlyand opened this issue Jul 19, 2023 · 0 comments
Open

[FEATURE] Support search for non-keyword fields for text #1887

Yury-Fridlyand opened this issue Jul 19, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Yury-Fridlyand
Copy link
Collaborator

Yury-Fridlyand commented Jul 19, 2023

Continuation of #1112.
Reference: https://faridrener.com/2018/05/07/es-multiple-datatypes.html

Is your feature request related to a problem?

DSL search requires exact types to match a function signature, but text fields could be of any type.
Mapping:

{
  "mappings": {
    "properties": {
      "TextWithMixedFields" : {
        "type" : "text",
        "fields" : {
          "numeric": {
            "type": "double",
            "ignore_malformed": true
          },
          "date": {
            "type": "date",
            "format": "dd.MM.uuuu",
            "ignore_malformed": true
          }
        }
      }
    }
  }
}

Data:

{"index": {}}
{ "TextWithMixedFields": "one two three" }
{"index": {}}
{ "TextWithMixedFields": 42 }
{"index": {}}
{ "TextWithMixedFields": "12.04.1961" }

Query 1:

select * from dbg where TextWithMixedFields > 0

Error:

{
  "reason": "Invalid SQL query",
  "details": "> function expected {[BYTE,BYTE],[SHORT,SHORT],[INTEGER,INTEGER],[LONG,LONG],[FLOAT,FLOAT],[DOUBLE,DOUBLE],[TEXT,TEXT],[STRING,STRING],[BOOLEAN,BOOLEAN],[DATE,DATE],[TIME,TIME],[DATETIME,DATETIME],[TIMESTAMP,TIMESTAMP],[INTERVAL,INTERVAL],[STRUCT,STRUCT],[ARRAY,ARRAY]}, but get [STRING,INTEGER]",
  "type": "ExpressionEvaluationException"
}

Query 2:

select * from dbg where TextWithMixedFields.numeric > 0;

Error:

{
  "reason": "Invalid SQL query",
  "details": "can't resolve Symbol(namespace=FIELD_NAME, name=TextWithMixedFields.numeric) in type env",
  "type": "SemanticCheckException"
}

What solution would you like?

A user should be able to search text for all type of fields.
Query 1:

select * from dbg where TextWithMixedFields > 0

Should fail with another error message OR automatically resolve field name and behave as second query.
Query 2:

select * from dbg where TextWithMixedFields.numeric > 0;

Should return

+-----------------------+
| TextWithMixedFields   |
|-----------------------|
| 42                    |
+-----------------------+

What alternatives have you considered?

N/A

Do you have any additional context?

This feature depends #1038, #1112 and #1113.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant