Skip to content

NPE on search request with fields parameter for pattern_text without a value #136049

@parkertimmins

Description

@parkertimmins

Elasticsearch Version

main (a2b2b26)

Installed Plugins

No response

Java Version

bundled

OS Version

6.8.0-79-generic #79~22.04.1-Ubuntu

Problem Description

If a search request is made using the fields parameter to get a pattern_text field which does not have any values, an NPE is returned.

Specifically, get this error:

Caused by: java.lang.NullPointerException: Cannot invoke "org.elasticsearch.xpack.logsdb.patterntext.PatternTextCompositeValues.advanceExact(int)" because "this.docValues" is null
        at org.elasticsearch.xpack.logsdb.patterntext.PatternTextFieldType$1.fetchValues(PatternTextFieldType.java:131)
        at [email protected]/org.elasticsearch.index.mapper.ValueFetcher.fetchDocumentField(ValueFetcher.java:59)
        at [email protected]/org.elasticsearch.search.fetch.subphase.FieldFetcher.fetch(FieldFetcher.java:177)
        at [email protected]/org.elasticsearch.search.fetch.subphase.FetchFieldsPhase$1.process(FetchFieldsPhase.java:149)
        at [email protected]/org.elasticsearch.search.fetch.FetchPhase$1.nextDoc(FetchPhase.java:232)
        at [email protected]/org.elasticsearch.search.fetch.FetchPhaseDocsIterator.iterate(FetchPhaseDocsIterator.java:9

Steps to Reproduce

PUT foo 
{
  "mappings": {
    "properties": {
      "field_with_value": {
        "type": "pattern_text"
      },
      "field_without_value": {
        "type": "pattern_text"
      }
    }
  }
}
PUT foo/_doc/1
{
  "field_with_value": "this is a value 123"
}

# this is ok
GET foo/_search
{
  "fields": [
    "field_with_value"
  ]
}

# this fails
GET foo/_search
{
  "fields": [
    "field_without_value"
  ]
}

# this also fails
GET foo/_search
{
  "fields": [
    "*"
  ]
}

Logs (if relevant)

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions