Skip to content

[BUG] Regex query doesn't support field alias #18214

Open
@bowenlan-amzn

Description

@bowenlan-amzn

Describe the bug

Reported by a customer, regex query is not working with alias field type.

Related component

Search

To Reproduce

curl -X PUT "localhost:9200/test_index" -H "Content-Type: application/json" -d'{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0
  },
  "mappings": {
    "properties": {
      "test": {
        "type": "text"
      },
      "test_alias": {
        "type": "alias",
        "path": "test"
      }
    }
  }
}'

curl -X POST "localhost:9200/_bulk" -H "Content-Type: application/json" -d'
{"index":{"_index":"test_index","_id":"1"}}
{"test":"hello"}
{"index":{"_index":"test_index","_id":"2"}}
{"test":"world"}
'

# search with field return doc 1
curl -X GET "localhost:9200/test_index/_search?pretty" -H "Content-Type: application/json" -d'{
  "query": {
    "query_string": {
      "query": "test: /h[a-z].*/"
    }
  }
}'

# Search using alias returns nothing
curl -X GET "localhost:9200/test_index/_search?pretty" -H "Content-Type: application/json" -d'{
  "query": {
    "query_string": {
      "query": "test_alias: /h[a-z].*/"
    }
  }
}'

Expected behavior

Search with field alias should work for regex query.

Additional Details

Metadata

Metadata

Assignees

Labels

SearchSearch query, autocomplete ...etcbugSomething isn't working

Type

No type

Projects

Status

🆕 New

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions