io.camunda.search.clients.core.SearchQueryRequest Maven / Gradle / Ivy
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
* one or more contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright ownership.
* Licensed under the Camunda License 1.0. You may not use this file
* except in compliance with the Camunda License 1.0.
*/
package io.camunda.search.clients.core;
import static io.camunda.search.clients.core.RequestBuilders.searchRequest;
import static io.camunda.util.CollectionUtil.addValuesToList;
import static io.camunda.util.CollectionUtil.collectValues;
import io.camunda.search.clients.query.SearchQuery;
import io.camunda.search.clients.query.SearchQueryBuilders;
import io.camunda.search.clients.sort.SearchSortOptions;
import io.camunda.search.clients.sort.SortOptionsBuilders;
import io.camunda.search.clients.source.SearchSourceConfig;
import io.camunda.search.clients.source.SourceConfigBuilders;
import io.camunda.util.ObjectBuilder;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
public record SearchQueryRequest(
List index,
SearchQuery query,
List sort,
Object[] searchAfter,
Integer from,
Integer size,
SearchSourceConfig source) {
public static SearchQueryRequest of(
final Function> fn) {
return searchRequest(fn);
}
public static final class Builder implements ObjectBuilder {
private List index;
private SearchQuery query;
private List sort;
private Object[] searchAfter;
private Integer from;
private Integer size;
private SearchSourceConfig source;
public Builder index(final List values) {
index = addValuesToList(index, values);
return this;
}
public Builder index(final String value, final String... values) {
return index(collectValues(value, values));
}
public Builder query(final SearchQuery value) {
query = value;
return this;
}
public Builder query(final Function> fn) {
return query(SearchQueryBuilders.query(fn));
}
public Builder sort(final List values) {
sort = addValuesToList(sort, values);
return this;
}
public Builder sort(final SearchSortOptions value, final SearchSortOptions... values) {
return sort(collectValues(value, values));
}
public Builder sort(
final Function> fn) {
return sort(SortOptionsBuilders.sort(fn));
}
public Builder searchAfter(final Object[] value) {
searchAfter = value;
return this;
}
public Builder size(final Integer value) {
size = value;
return this;
}
public Builder from(final Integer value) {
from = value;
return this;
}
public Builder source(final SearchSourceConfig value) {
source = value;
return this;
}
public Builder source(
final Function> fn) {
return source(SourceConfigBuilders.sourceConfig(fn));
}
@Override
public SearchQueryRequest build() {
return new SearchQueryRequest(
Objects.requireNonNull(
index, "Expected to create request for index, but given index was null."),
query,
sort,
searchAfter,
from,
size,
source);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy