# Search by runtime fields using wildcards

**URL:** <https://discuss.elastic.co/t/search-by-runtime-fields-using-wildcards/280933>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [August 10, 2021, 1:37pm UTC](https://discuss.elastic.co/t/search-by-runtime-fields-using-wildcards/280933 "2021-08-10T13:37:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Hulevsky](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_hulevsky/32/77188_2.png) [@Mark\_Hulevsky](https://discuss.elastic.co/u/Mark_Hulevsky)\
**Post date:** [August 10, 2021, 1:37pm UTC](https://discuss.elastic.co/t/search-by-runtime-fields-using-wildcards/280933/1 "2021-08-10T13:37:10Z")

</div>

Hi, I'm trying to search by runtime field using wildcards.  
Here is my mapping.

```auto
"mappings": {
            "runtime": {
                "totalCostRounded": {
                    "type": "keyword",
                    "script": {
                        "source": "double f = Math.round(doc['totalCost'].value * 100.0) / 100.0; emit(f.toString())",
                        "lang": "painless"
                    }
                }
            },
            "properties": {
                "id": {
                    "type": "keyword"
                },
                "totalCost": {
                    "type": "double"
                }
            }
        }

```

This is the example of my query.

```auto
{
    "query": {
        "query_string": {
            "query": "**",
            "fields": [
                "id",
                "totalCostRounded"
            ],
            "analyze_wildcard": true,
            "type": "cross_fields",
            "default_operator": "and"
        }
    }
}

```

When I execute it I get this error

```auto
{
    "error": {
        "root_cause": [
            {
                "type": "query_shard_exception",
                "reason": "Can only use wildcard queries on keyword, text and wildcard fields - not on [totalCostRounded] which is of type [keyword]",
                "index_uuid": "lxAtOpcfTaaMGExV5YBqXA",
                "index": "bill-index"
            }
        ],
        "type": "search_phase_execution_exception",
        "reason": "all shards failed",
        "phase": "query",
        "grouped": true,
        "failed_shards": [
            {
                "shard": 0,
                "index": "bill-index",
                "node": "9GF54jKcQluU_UkFbzLFtA",
                "reason": {
                    "type": "query_shard_exception",
                    "reason": "Can only use wildcard queries on keyword, text and wildcard fields - not on [totalCostRounded] which is of type [keyword]",
                    "index_uuid": "lxAtOpcfTaaMGExV5YBqXA",
                    "index": "bill-index"
                }
            }
        ]
    },
    "status": 400
}

```

This query works fine with other properties.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 7, 2021, 1:37pm UTC](https://discuss.elastic.co/t/search-by-runtime-fields-using-wildcards/280933/2 "2021-09-07T13:37:56Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
