/** * Returns the facet filters collected when creating the result * * @return the facet filters defined by the query */ public List<Facet> getFacets() { if (facetsProcessed.firstCall() && response != null) { for (Facet facet : termFacets) { fillFacet(facet); } } return termFacets; }
/** * Adds a parameter to the url. * * @param key the name of the parameter * @param value the value of the parameter . If the given value is <tt>null</tt> an empty parameter will be added. * @param urlEncode <tt>true</tt> if the given value should be url encoded before adding * @return the builder itself for fluent method calls */ public URLBuilder addParameter(@Nonnull String key, @Nullable Object value, boolean urlEncode) { if (questionMark.firstCall()) { url.append("?"); } else { url.append("&"); } url.append(key); url.append("="); String stringValue = value == null ? "" : value.toString(); if (urlEncode) { stringValue = Strings.urlEncode(stringValue); } url.append(stringValue); return this; }
private static void reportUnknownType(Output output, String typeName) { output.line("Unknown type: " + typeName); Monoflop mf = Monoflop.create(); for (String name : index.getSchema().getTypeNames()) { if (name.toLowerCase().contains(typeName.toLowerCase())) { if (mf.firstCall()) { output.line("Did you mean one of those: "); } output.line(" * " + name); } } }
@Override public QueryBuilder createQuery() { if (parsed.firstCall()) { LookaheadReader reader = new LookaheadReader(new StringReader(input)); QueryBuilder main = parseQuery(reader); if (!reader.current().isEndOfInput()) { IndexAccess.LOG.FINE("Unexpected character in query: " + reader.current()); } // If we cannot compile a query from a non empty input, we probably dropped all short tokens // like a search for "S 8" would be completely dropped. Therefore we resort to "S8". if (main == null && !Strings.isEmpty(input) && input.contains(" ")) { reader = new LookaheadReader(new StringReader(input.replaceAll("\\s", ""))); main = parseQuery(reader); } finishedQuery = main; } return finishedQuery; }
protected QueryBuilder transformTokenList(String field, List<String> tokens) { if (tokens.size() == 1) { return QueryBuilders.termQuery(field, tokens.get(0)); } else { Monoflop monoflop = Monoflop.create(); SpanNearQueryBuilder builder = null; for (String token : tokens) { if (monoflop.firstCall()) { builder = QueryBuilders.spanNearQuery(QueryBuilders.spanTermQuery(field, token), 3); } else { builder.addClause(QueryBuilders.spanTermQuery(field, token)); } } return builder; } } }
@Override public SpanQueryBuilder createSpanQuery() { Monoflop mflop = Monoflop.create(); SpanOrQueryBuilder builder = null; for (Constraint constraint : constraints) { if (constraint instanceof SpanConstraint) { SpanConstraint spanConstraint = (SpanConstraint) constraint; if (mflop.firstCall()) { builder = QueryBuilders.spanOrQuery(spanConstraint.createSpanQuery()); } else { builder.addClause(spanConstraint.createSpanQuery()); } } else { throw new UnsupportedOperationException( "Or-Constraint contains a non span constraint, which is not allowed!"); } } return builder; }
@Override public SpanNearQueryBuilder createQuery() { Monoflop mflop = Monoflop.create(); SpanNearQueryBuilder builder = null; for (SpanConstraint constraint : constraints) { if (mflop.firstCall()) { builder = QueryBuilders.spanNearQuery(constraint.createSpanQuery(), slop).inOrder(inOrder).boost(boost); } else { builder.addClause(constraint.createSpanQuery()).inOrder(inOrder).boost(boost); } } return builder; }
Monoflop mf = Monoflop.create(); for (Document doc : cur) { if (mf.firstCall()) { handleTracingAndReporting(collection, w);