{
"query": {
"function_score": {
"query": { "bool": { "filter": [ { "terms": { "id" : [ "4", "2", "1", "3" ] } } ] } },
"boost": "1",
"functions": [
{
"filter": { "match": { "id": "4" } },
"weight": 4
},
{
"filter": { "match": { "id": "2" } },
"weight": 3
},
{
"filter": { "match": { "id": "1" } },
"weight": 2
},
{
"filter": { "match": { "id": "3" } },
"weight": 1
},
],
"max_boost": 4,
"score_mode": "first",
"boost_mode": "replace",
"min_score" : 1
}
},
"sort": [
{
"_score": {
"order": "desc"
}
}
]
}
-Xmx 5G
), либо удаляйте/схлопывайте по количеству шардов существующие индексы, либо добавляйте ноды. ES_URL='http://elasticsearch_address:port' #URL эластика
ATTR_NAME="storage_type" #аттрибут ноды, устанавливается в elasticsearch.yml
ATTR_WARM="hdd" #значение аттрибута, соответствующий "тёплой" ноде
N=3 #количество календарных дней до передвижения индекса
END_DATE=$(date --date="$N days ago" -I)
for INDEX in $(curl -s "$ES_URL"'/_cat/indices?h=index,creation.date.string&format=json' |
jq -rc '.[] | select(."creation.date.string" < "3*") | .index')
do
curl -s -XPUT "${ES_URL}/${INDEX}/_settings" -d "{\"index.routing.allocation.require.${ATTR_NAME}\":\"{ATTR_WARM}\"}"
if [ $& -eq]
then
echo "$INDEX has been set up"
else
echo "Error while setting up $INDEX"
ERRORS=
fi
done
if [[ -v $ERRORS ]]
then
exit 1
fi
{
"settings": {
"analysis": {
"analyzer": {
"address_analyzer_toster": {
"tokenizer": "whitespace",
"char_filter": [
"useless_symbols",
],
"filter": "useless_words": {
"type": "stop",
"stopwords": ["ул", "д", "проезд", ...]
}
}
},
"char_filter": {
"useless_symbols": {
"type": "pattern_replace",
"pattern": "[,\.:].*",
"replacement": ""
}
}
}
}
}