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
andorder_id
because I want to always show latest transactions for particular user. -
query_field
is text and combination ofname
anddescription
because I want users to query something like "Phone bill" or "John Doe". Can I setname
anddescription
askeyword
and then save them totext
inquery_field
? -
order_id
is "index": false, but I sort index byorder_id
, is that even possible?