private QueryBuilder buildSearchQuery() { BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder(); for (ElasticsearchColumnHandle column : columns) { BoolQueryBuilder columnQueryBuilder = new BoolQueryBuilder(); Type type = column.getColumnType(); if (tupleDomain.getDomains().isPresent()) { Domain domain = tupleDomain.getDomains().get().get(column); if (domain != null) { columnQueryBuilder.should(buildPredicate(column.getColumnJsonPath(), domain, type)); } } boolQueryBuilder.must(columnQueryBuilder); } if (boolQueryBuilder.hasClauses()) { return boolQueryBuilder; } return new MatchAllQueryBuilder(); }
/** * Creates a function_score query that executes the provided filters and functions on all documents * * @param filterFunctionBuilders the filters and functions */ public FunctionScoreQueryBuilder(FilterFunctionBuilder[] filterFunctionBuilders) { this(new MatchAllQueryBuilder(), filterFunctionBuilders); }
/** * A query that matches on all documents. */ public static MatchAllQueryBuilder matchAllQuery() { return new MatchAllQueryBuilder(); }
public FilterFunctionBuilder(ScoreFunctionBuilder<?> scoreFunctionBuilder) { this(new MatchAllQueryBuilder(), scoreFunctionBuilder); }
/** * Creates a function_score query that will execute the function provided on all documents * * @param scoreFunctionBuilder score function that is executed */ public FunctionScoreQueryBuilder(ScoreFunctionBuilder<?> scoreFunctionBuilder) { this(new MatchAllQueryBuilder(), new FilterFunctionBuilder[]{new FilterFunctionBuilder(scoreFunctionBuilder)}); }
/** * BWC serialization for collapsing {@link InnerHitBuilder}. * Should only be used to send collapsing inner hits to nodes pre 5.5. */ public void writeToCollapseBWC(StreamOutput out) throws IOException { assert out.getVersion().before(Version.V_5_5_0) : "invalid output version, must be < " + Version.V_5_5_0.toString(); writeToBWC(out, new MatchAllQueryBuilder(), null, null); }
@Override protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException { BoolQueryBuilder newBuilder = new BoolQueryBuilder(); boolean changed = false; final int clauses = mustClauses.size() + mustNotClauses.size() + filterClauses.size() + shouldClauses.size(); if (clauses == 0) { return new MatchAllQueryBuilder().boost(boost()).queryName(queryName()); } changed |= rewriteClauses(queryRewriteContext, mustClauses, newBuilder::must); changed |= rewriteClauses(queryRewriteContext, mustNotClauses, newBuilder::mustNot); changed |= rewriteClauses(queryRewriteContext, filterClauses, newBuilder::filter); changed |= rewriteClauses(queryRewriteContext, shouldClauses, newBuilder::should); // lets do some early termination and prevent any kind of rewriting if we have a mandatory query that is a MatchNoneQueryBuilder Optional<QueryBuilder> any = Stream.concat(newBuilder.mustClauses.stream(), newBuilder.filterClauses.stream()) .filter(b -> b instanceof MatchNoneQueryBuilder).findAny(); if (any.isPresent()) { return any.get(); } if (changed) { newBuilder.adjustPureNegative = adjustPureNegative; newBuilder.minimumShouldMatch = minimumShouldMatch; newBuilder.boost(boost()); newBuilder.queryName(queryName()); return newBuilder; } return this; }
public static QueryBuilder simpleQueryBuilder(String q, boolean or, Boosts boosts) { if (q.equals("yacyall")) return new MatchAllQueryBuilder(); final MultiMatchQueryBuilder qb = QueryBuilders .multiMatchQuery(q) .operator(or ? Operator.OR : Operator.AND) .zeroTermsQuery(ZeroTermsQuery.ALL); boosts.forEach((mapping, boost) -> qb.field(mapping.getMapping().name(), boost)); return qb; }
if ((from() != null && from().toString().contains("now")) || (to() != null && to().toString().contains("now"))) { return new MatchAllQueryBuilder();
/** * A query that matches on all documents. */ public static MatchAllQueryBuilder matchAllQuery() { return new MatchAllQueryBuilder(); }
/** * Creates a function_score query that executes the provided filters and functions on all documents * * @param filterFunctionBuilders the filters and functions */ public FunctionScoreQueryBuilder(FilterFunctionBuilder[] filterFunctionBuilders) { this(new MatchAllQueryBuilder(), filterFunctionBuilders); }
/** * Creates a function_score query that executes the provided filters and functions on all documents * * @param filterFunctionBuilders the filters and functions */ public FunctionScoreQueryBuilder(FilterFunctionBuilder[] filterFunctionBuilders) { this(new MatchAllQueryBuilder(), filterFunctionBuilders); }
/** * Creates a function_score query that executes the provided filters and functions on all documents * * @param filterFunctionBuilders the filters and functions */ public FunctionScoreQueryBuilder(FilterFunctionBuilder[] filterFunctionBuilders) { this(new MatchAllQueryBuilder(), filterFunctionBuilders); }
/** * A query that match on all documents. */ public static MatchAllQueryBuilder matchAllQuery() { return new MatchAllQueryBuilder(); }
public FilterFunctionBuilder(ScoreFunctionBuilder<?> scoreFunctionBuilder) { this(new MatchAllQueryBuilder(), scoreFunctionBuilder); }
filter = new MatchAllQueryBuilder();
query = new MatchAllQueryBuilder();
/** * BWC serialization for collapsing {@link InnerHitBuilder}. * Should only be used to send collapsing inner hits to nodes pre 5.5. */ public void writeToCollapseBWC(StreamOutput out) throws IOException { assert out.getVersion().before(Version.V_5_5_0) : "invalid output version, must be < " + Version.V_5_5_0.toString(); writeToBWC(out, new MatchAllQueryBuilder(), null, null); }
/** * BWC serialization for collapsing {@link InnerHitBuilder}. * Should only be used to send collapsing inner hits to nodes pre 5.5. */ public void writeToCollapseBWC(StreamOutput out) throws IOException { assert out.getVersion().before(Version.V_5_5_0) : "invalid output version, must be < " + Version.V_5_5_0.toString(); writeToBWC(out, new MatchAllQueryBuilder(), null, null); }
/** * BWC serialization for collapsing {@link InnerHitBuilder}. * Should only be used to send collapsing inner hits to nodes pre 5.5. */ public void writeToCollapseBWC(StreamOutput out) throws IOException { assert out.getVersion().before(Version.V_5_5_0) : "invalid output version, must be < " + Version.V_5_5_0.toString(); writeToBWC(out, new MatchAllQueryBuilder(), null, null); }