se.l4.silo.search.QueryCriteriaBuilder Maven / Gradle / Ivy
Show all versions of silo-search-api Show documentation
package se.l4.silo.search;
import java.util.function.Supplier;
import se.l4.silo.search.query.AndQuery;
import se.l4.silo.search.query.ConstantScoreQuery;
import se.l4.silo.search.query.FieldQuery;
import se.l4.silo.search.query.NegateQuery;
import se.l4.silo.search.query.OrQuery;
import se.l4.silo.search.query.QueryReceiver;
import se.l4.silo.search.query.RangeQuery;
import se.l4.silo.search.query.SuggestQuery;
import se.l4.silo.search.query.UserQuery;
public interface QueryCriteriaBuilder
extends QueryReceiver
{
> P query(P q);
default
> P query(Supplier
supplier)
{
return query(supplier.get());
}
default UserQuery user(String... fields)
{
return query(new UserQuery<>(fields));
}
default OrQuery or()
{
return query(new OrQuery<>());
}
default AndQuery and()
{
return query(new AndQuery<>());
}
default NegateQuery negate()
{
return query(new NegateQuery<>());
}
default FieldQuery field(String field)
{
return query(new FieldQuery<>(field));
}
default ConstantScoreQuery constantScore(float score)
{
return query(new ConstantScoreQuery<>(score));
}
default SuggestQuery suggest(String field)
{
return query(new SuggestQuery<>(field));
}
default RangeQuery number(String field)
{
return query(new RangeQuery<>(field));
}
}