package com.arms.egovframework.javaservice.esframework.esquery.must;

import org.opensearch.index.query.AbstractQueryBuilder;
import org.opensearch.index.query.Operator;
import org.opensearch.index.query.QueryBuilders;
import org.opensearch.index.query.QueryStringQueryBuilder;

public class QueryStringMust extends Must<QueryStringQueryBuilder> {

    private QueryStringQueryBuilder queryBuilder;

    private QueryStringMust(String queryString){
        if(queryString!=null){
            this.queryBuilder = QueryBuilders.queryStringQuery(queryString);
        }
    }

    public static QueryStringMust of(String queryString){
        return new QueryStringMust(queryString);
    }

    public QueryStringMust operator(Operator operator){
        if(operator!=null){
            this.queryBuilder.defaultOperator(operator);
        }
        return this;
    }

    @Override
    public AbstractQueryBuilder<QueryStringQueryBuilder> abstractQueryBuilder() {
        return queryBuilder;
    }
}
