Search by runtime fields using wildcards

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

"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.

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

When I execute it I get this error

{
    "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.

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