com.blackbirdai.client.model.QueryComponent Maven / Gradle / Ivy
package com.blackbirdai.client.model;
import com.blackbirdai.client.InvalidRequestException;
import com.blackbirdai.client.util.Encoders;
import java.util.Collections;
import java.util.List;
/**
* Container for query-component. Used for /msearch API.
*/
public class QueryComponent {
private final String query;
private final List filters;
/**
* Constructor for QueryComponent.
*/
public QueryComponent(String query, List filters) {
this.query = query;
this.filters = filters;
}
/**
* Constructor for QueryComponent with no filter.
*/
public QueryComponent(String query) {
this.query = query;
this.filters = Collections.EMPTY_LIST;
}
/**
* For internal use.
*/
StringBuilder appendQueryStr(StringBuilder builder) throws InvalidRequestException {
builder.append("qc=q=");
builder.append(Encoders.urlEncode(query));
for (FilterParam filter: filters) {
builder.append("//");
filter.appendQueryStr(builder);
}
return builder;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy