package at.procon.dip.search.dto;

import at.procon.dip.domain.access.DocumentVisibility;
import at.procon.dip.domain.document.DocumentFamily;
import at.procon.dip.domain.document.DocumentType;
import at.procon.dip.domain.document.RepresentationType;
import jakarta.validation.constraints.NotBlank;
import java.time.OffsetDateTime;
import java.util.Set;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SearchRequest {

    @NotBlank
    private String queryText;

    @Builder.Default
    private Set<SearchMode> modes = Set.of(SearchMode.HYBRID);

    private Set<DocumentType> documentTypes;
    private Set<DocumentFamily> documentFamilies;
    private Set<DocumentVisibility> visibilities;
    private Set<String> languageCodes;
    private Set<RepresentationType> representationTypes;
    private OffsetDateTime createdFrom;
    private OffsetDateTime createdTo;
    private java.util.List<DocumentAttributeFilterRequest> attributeFilters;

    private Integer page;
    private Integer size;

    @Builder.Default
    private SearchSortMode sortMode = SearchSortMode.SCORE_DESC;

    @Builder.Default
    private boolean collapseByDocument = true;

    @Builder.Default
    private SearchRepresentationSelectionMode representationSelectionMode =
            SearchRepresentationSelectionMode.PRIMARY_AND_CHUNKS;

    /**
     * Optional semantic model key used only by the semantic search engine.
     * When omitted, the new embedding subsystem default query model is used.
     */
    private String semanticModelKey;

    /**
     * Optional per-request similarity threshold override for semantic search.
     */
    private Double semanticSimilarityThreshold;
}
