OpenSearch icon indicating copy to clipboard operation
OpenSearch copied to clipboard

[BUG] Error not returned when creating a percolator document containing a field without mapping

Open tokki92 opened this issue 1 year ago • 1 comments

Describe the bug

If an asterisk is included in the value of the query field when creating a percolator document with query_string, query_shard_exception (No field mapping can be found for the field with name [{someField}]) is not returned even if there is no mapping of that field. And that field is not searchable.

Related component

Indexing

To Reproduce

request

PUT /:index/_doc/:id

{
  "query": {
    "query_string": {
      "query": "someField: *test",
      "default_operator": "AND",
      "default_field": "body"
    }
  }
}

then this percolator document is created successfully even if someField has no mapping in its index and someField is not searchable

Expected behavior

When the request body is(no asterisk)

{
  "query": {
    "query_string": {
      "query": "someField: test",
      "default_operator": "AND",
      "default_field": "body"
    }
  },
}

cluster returns 400 Bad Requeest response with query_shard_exception(reason: No field mapping can be found for the field with name [someField])

Additional Details

Plugins Please list all plugins currently enabled.

Screenshots If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

index settings

  • I don't think there is a relevant setting
"settings": {
      "index": {
        "replication": {
          "type": "DOCUMENT"
        },
        "refresh_interval": "3s",
        "number_of_shards": "1",
        "provided_name": "{index name}",
        "creation_date": "1706062096956",
        "number_of_replicas": "3",
        "uuid": "Dur7_p13SgOIwl-3rHt_BQ",
        "version": {
          "created": "136327927"
        }
      }
    }

tokki92 avatar Feb 02 '24 00:02 tokki92

@tokki92 Feel free to raise a pull request for the fix.

ankitkala avatar Feb 15 '24 11:02 ankitkala