# Elasticsearch template in Logstash doesn't mapping and not able to sort fields

**URL:** <https://discuss.elastic.co/t/elasticsearch-template-in-logstash-doesnt-mapping-and-not-able-to-sort-fields/259937>\
**Category:** Logstash\
**Created:** [December 31, 2020, 7:30am UTC](https://discuss.elastic.co/t/elasticsearch-template-in-logstash-doesnt-mapping-and-not-able-to-sort-fields/259937 "2020-12-31T07:30:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rknd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rknd/32/103882_2.png) [@rknd](https://discuss.elastic.co/u/rknd)\
**Post date:** [December 31, 2020, 7:30am UTC](https://discuss.elastic.co/t/elasticsearch-template-in-logstash-doesnt-mapping-and-not-able-to-sort-fields/259937/1 "2020-12-31T07:30:18Z")

</div>

I want to sort datas via elasticsearch rest client, **I want to get data that match with the name "match\_field", after this match sort via "int\_var"** , below is my template in logstash.

```auto
{
  "index_patterns": ["index_name"],
  "template": {
    "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 0
    },
    "mappings": {
      "_doc": {
          "properties": {
              "int_var": {
                  "type": "keyword"
              }
          }
      }
    }
  }
}

```

When I try to reach, with the below code

```auto
{
        "size": 100,
        "query": {
            "bool": {
                "must": {
                    "match": {
                        "match_field": user_request
                    }
                }
            }
        },
        "sort": [
            {"int_var": {"order": "asc"}}
        ]
    }

```

I've got this error

```auto
Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true

```

How can i solve this ? Thanks for answering

---

<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:** [January 28, 2021, 7:30am UTC](https://discuss.elastic.co/t/elasticsearch-template-in-logstash-doesnt-mapping-and-not-able-to-sort-fields/259937/2 "2021-01-28T07:30:26Z")

</div>

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