package cn.reghao.tnb.search.esapp.model.vo;

import lombok.Getter;
import lombok.Setter;
import org.apache.lucene.search.Query;

import java.util.Set;

/**
 * @author reghao
 * @date 2025-08-22 15:14:50
 */
@Getter
@Setter
public class LuceneQuery {
    private int pageSize;
    private int pageNumber;
    private String indexName;
    private Set<String> highlightFiledNames;
    private Query query;

    public LuceneQuery() {
        this.pageSize = 10;
        this.pageNumber = 1;
    }

    private LuceneQuery(Builder builder) {
        this.pageSize = builder.pageSize;
        this.pageNumber = builder.pageNumber;
        this.indexName = builder.indexName;
        this.highlightFiledNames = builder.highlightFiledNames;
        this.query = builder.query;
    }

    public static final class Builder {
        private int pageSize;
        private int pageNumber;
        private String indexName;
        private Set<String> highlightFiledNames;
        private Query query;

        public Builder pageSize(int pageSize) {
            this.pageSize = pageSize;
            return this;
        }

        public Builder pageNumber(int pageNumber) {
            this.pageNumber = pageNumber;
            return this;
        }

        public Builder indexName(String indexName) {
            this.indexName = indexName;
            return this;
        }

        public Builder highlightFiledNames(Set<String> highlightFiledNames) {
            this.highlightFiledNames = highlightFiledNames;
            return this;
        }

        public Builder query(Query query) {
            this.query = query;
            return this;
        }

        public LuceneQuery build() {
            return new LuceneQuery(this);
        }
    }
}
