我們今天進到查詢的最後一個部分
也就是在查詢時,要怎麼操作才能讓查詢
更加迅速以及比較不消耗資源呢?
可以分成幾個方面去探討:
系統優化:
目標索引的處理:
{
  "mappings": {
    "properties": {
      "first_name": {
        "type": "text",
        "copy_to": "full_name"
      },
      "last_name": {
        "type": "text",
        "copy_to": "full_name"
      },
      "full_name": {
        "type": "text"
      }
    }
  }
}
PUT /index_name
{
  "settings": {
    "index.store.preload": ["nvd", "dvd"] // nvd:norms dvd:doc values
  }
}
max(max_failures, ceil(num_nodes / num_primaries) - 1)
// max_failures代表能接受多少node掛掉
控制結果部分:
"_source": false
"_source": "created"
"_source": "field.key"
"_source": "field.*"
"_source": ["field.*", "other_fields"]
"_source": {"includes": "", "excludes": ""}
"date_field": { "gte": "now-1h", "lte": "now/"} 
//可以改成如下
"date_field": { "gte": "now-1h/m", "lte": "now/m"}
{
	"range": {
		"my_date": {
		"gte": "now-1h",
		"lte": "now-1h/m"
		}
	}
},
{
	"range": {
		"my_date": {
		"gte": "now-1h/m",
		"lte": "now/m"
		}
	}
},
{
	"range": {
		"my_date": {
		"gte": "now/m",
		"lte": "now"
		}
	}
}
以上就是有關查詢相關的性能優化~
希望大家在使用上能夠更加了解應該要怎麼處理自己的資料
明天的文章我們會再重新探討有關整個ES集群是怎麼被建立起來的
探討多節點要怎麼互相找到彼此,以及建立起一整個cluster
參考資料
turn for search speed:
https://www.elastic.co/guide/en/elasticsearch/reference/current/tune-for-search-speed.html
查詢資料優化:
https://ithelp.ithome.com.tw/articles/10252695