Home > other >  Search all field-names matching wildcard in a wildcard query in Elasticsearch 6.0?
Search all field-names matching wildcard in a wildcard query in Elasticsearch 6.0?

Time:02-22

I want to run a wildcard query on all fields that match a wildcard. I know this is possible using a query_string query, but can it be done using a wildcard query?

Index mapping:

{
  "rdbms_db": {
    "properties": {
      "name": {
        "type": "text",
        "fields": {
          "raw": {
            "type": "keyword"
          }
        },
        "copy_to": [
          "all"
        ]
      },
      "title": {
        "type": "text",
        "copy_to": [
          "all"
        ]
      }
    }
  },
  "rdbms_table": {
    "properties": {
      "name": {
        "type": "text",
        "fields": {
          "raw": {
            "type": "keyword"
          }
        },
        "copy_to": [
          "all"
        ]
      },
      "title": {
        "type": "text",
        "copy_to": [
          "all"
        ]
      }
    }
  }
}

The following query does not return any results:

{
  "query": {
    "bool": {
      "filter": [
        {
          "wildcard": {
            "*.name.raw": "test*"
          }
        }
      ]
    }
  }
}

However, when I use the actual field-name rdbms_table.name.raw, I get accurate results. Thanks in advance for any help provided!

CodePudding user response:

The wildcard query does not support wildcarded field names in ES 6.

In ES 8 that just got released, it's still not possible to do it.

  • Related