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

Inconsistent handling of empty strings in numerical fields between ingestion and fetch #87153

Open
iverase opened this issue May 26, 2022 · 1 comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team

Comments

@iverase
Copy link
Contributor

iverase commented May 26, 2022

If we try to index a document with an empty string on a field that is declared numerical, e.g. an integer, the document is ingested without issues:

PUT test
{
  "mappings": {
    "properties": {
      "numerical_field": {
        "type": "integer"
      }
    }
  }
}
PUT test/_doc/1
{
  "numerical_field": ""
}

This is due to coerce being true by default which makes empty strings to be treated as null values. This behaviour is not documented and should be added to the docs.

The issue is when we try to fetch this document using the fields API:

GET test/_search
{
  "_source": false, 
  "fields": ["numerical_field"]
}

{
  "took" : 0,
  "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" : "1",
        "_score" : 1.0,
        "ignored_field_values" : {
          "numerical_field" : [
            ""
          ]
        }
      }
    ]
  }
}

The field is treated as malformed and added to ignored fields which seems inconsistent whit the ingestion time behaviour.

@iverase iverase added >bug :Search/Search Search-related issues that do not fall into other categories labels May 26, 2022
@elasticmachine elasticmachine added the Team:Search Meta label for search team label May 26, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team
Projects
None yet
Development

No branches or pull requests

2 participants