All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.searchbox.indices.aliases.AliasMapping Maven / Gradle / Ivy

package io.searchbox.indices.aliases;

import org.apache.commons.lang3.StringUtils;

import java.util.*;

/**
 * @author cihat keser
 */
public abstract class AliasMapping {

    protected List indices = new LinkedList();
    protected String alias;
    protected Map filter;
    protected List searchRouting = new LinkedList();
    protected List indexRouting = new LinkedList();

    public abstract String getType();

    public List> getData() {
        List> retList = new LinkedList>();

        for (String index : indices) {
            Map paramsMap = new LinkedHashMap();
            paramsMap.put("index", index);
            paramsMap.put("alias", alias);

            if (filter != null) {
                paramsMap.put("filter", filter);
            }

            if (searchRouting.size() > 0) {
                paramsMap.put("search_routing", StringUtils.join(searchRouting, ","));
            }

            if (indexRouting.size() > 0) {
                paramsMap.put("index_routing", StringUtils.join(indexRouting, ","));
            }

            Map actionMap = new LinkedHashMap();
            actionMap.put(getType(), paramsMap);
            retList.add(actionMap);
        }

        return retList;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy