# Mapping reccomendations

**URL:** <https://discuss.elastic.co/t/mapping-reccomendations/196273>\
**Category:** Elasticsearch\
**Created:** [August 22, 2019, 8:40am UTC](https://discuss.elastic.co/t/mapping-reccomendations/196273 "2019-08-22T08:40:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ansamHox](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@ansamHox](https://discuss.elastic.co/u/ansamHox)\
**Post date:** [August 22, 2019, 8:40am UTC](https://discuss.elastic.co/t/mapping-reccomendations/196273/1 "2019-08-22T08:40:41Z")

</div>

I am using 7.3 to display transactions in my mobile app. When user logs in, it shows last 5 transactions. If he **clicks** on "transaction history" (opens new page with the same list but with filter in header and load more button in footer) **then** user is able to perform search/filter operations (select date, amount range or find via description and name field). My approach is to set all fields to "index": false except one new field "query\_field" which is copy field of "name" and "description" so users can search on them. Is this ok approach, and can I put "description" field as "keyword" but store it in copy field as text. I want just faster performances on app loading.

```
PUT _template/history_tx
{
  "index_patterns": [
    "transactions*"
  ],
  "settings": {
    "index": {
      "number_of_shards": "3",
      "number_of_replicas": "2",
      "sort.field": [
        "account_id",
        "date",
        "order_id"
      ],
      "sort.order": [
        "desc",
        "desc",
        "desc"
      ]
    }
  },
  "mappings": {
    "_routing": {
      "required": true
    },
    "properties": {
      "@timestamp": {
        "type": "date",
        "format": "strict_date_optional_time||epoch_millis",
        "doc_values": false,
        "index": false
      },
      "query_field": {
        "type": "text"
      },
      "order_id": {
        "type": "keyword",
        "index": false
      },
      "date": {
        "type": "date",
        "format": "strict_year_month_day"
      },
      "initiator": {
        "type": "double",
        "index": false
      },
      "amount_before": {
        "type": "double",
        "index": false
      },
      "message": {
        "type": "keyword",
        "index": false
      },
      "account_id": {
        "type": "keyword",
        "index": false
      },
      "description": {
        "type": "text",
        "index": false,
        "copy_to": "query_field"
      },
      "order_type_id": {
        "type": "long",
        "index": false
      },
      "v_pnb": {
        "type": "keyword",
        "index": false,
        "doc_values": false
      },
      "currency_id": {
        "type": "keyword"
      },
      "vd_amount": {
        "type": "double",
        "index": false,
        "doc_values": false
      },
      "name": {
        "type": "text",
        "index": false,
        "copy_to": "query_field"
      }
    }
  }
}

```

- Sorting by `user_id`, `date` and `order_id` because I want to always show latest transactions for particular user.

- `query_field` is text and combination of `name` and `description` because I want users to query something like "Phone bill" or "John Doe". Can I set `name` and `description` as `keyword` and then save them to `text` in `query_field`?

- `order_id` is **"index": false** , but I sort index by `order_id`, is that even possible?

---

<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 19, 2019, 8:40am UTC](https://discuss.elastic.co/t/mapping-reccomendations/196273/2 "2019-09-19T08:40:44Z")

</div>

Closed on September 19, 2019, 8:40am UTC

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