package com.ruoyi.web.util;

import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.client.core.CountRequest;

/**
 * @Describe es工具
 * @Author xiatao
 * @Date 2022/1/19 11:08
 **/
public class EsUtil {

    public enum EsEnum {

        BID("bid_", "_doc"),
        COMPANY("company", "_doc"),
        ;
        private String index;
        private String type;

        public SearchRequest getSearchRequest() {
            SearchRequest searchRequest = new SearchRequest(index);
            searchRequest.types(type);
            return searchRequest;
        }
        public CountRequest getCountRequest() {
            CountRequest countRequest = new CountRequest(index);
            countRequest.types(type);
            return countRequest;
        }

        EsEnum(String index, String type) {
            this.index = index;
            this.type = type;
        }

        public String getIndex() {
            return index;
        }

        public void setIndex(String index) {
            this.index = index;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }
    }


}
