Skip to content

‘exists’ query not working for nested docs with norms=false #80309

Closed
@amatoba

Description

@amatoba

Elasticsearch version (bin/elasticsearch --version): 7.15.1

Plugins installed: []

JVM version (java -version): 11.0.9

OS version (uname -a if on a Unix-like system): Darwin Kernel Version 20.6.0

Description of the problem including expected versus actual behavior:

For fields within nested docs with norms disabled, querying for their existence via 'exists' query appears to not be working. It does however work when norms are enabled. This works with 7.10.2, but no longer does in 7.14.1/7.15.1

Thanks for your help!

Steps to reproduce:
1.

curl -XPUT localhost:9200/test -d '{
	"mappings": {
		"properties": {
			"user": {
				"type": "nested",
				"properties": {
					"first": {
						"type": "text",
						"norms": false
					},
					"last": {
						"type": "text"
					}
				}
			}
		}
	}
}'
curl -XPUT localhost:9200/test/_doc/1 -d '{
  "user" : [
    {
      "first" : "John",
      "last" :  "Smith"
    }
  ]
}'
  1. Fails to find via user.first
curl -XGET localhost:9200/test/_search -d '{
	"query": {
		"nested": {
			"path": "user",
			"query": {
				"exists": {
					"field": "user.first"
				}
			}
		}
	}
}'
  1. Succeeds to find via user.last
curl -XGET localhost:9200/test/_search -d '{
	"query": {
		"nested": {
			"path": "user",
			"query": {
				"exists": {
					"field": "user.last"
				}
			}
		}
	}
}'

Provide logs (if relevant):

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Search/SearchSearch-related issues that do not fall into other categories>bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions