Skip to content

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

Closed as not planned

Description

@Yury-Fridlyand

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.

Activity

  1. added
    enhancement
    on Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions