private double resolveScoreThreshold(Query query) { return Double.valueOf(query.properties().getString(WAND_SCORE_THRESHOLD, "0")); }
private String createQuerySelectionString() { String s = query.properties().getString(streamingUserid); if (s != null) { return "id.user==" + s; } s = query.properties().getString(streamingGroupname); if (s != null) { return "id.group==\"" + s + "\""; } return query.properties().getString(streamingSelection); }
private int resolveHeapSize(Query query) { String defaultHeapSize = "100"; return Integer.valueOf(query.properties().getString(WAND_HEAP_SIZE, defaultHeapSize)); }
private double resolveThresholdBoostFactor(Query query) { return Double.valueOf(query.properties().getString(WAND_THRESHOLD_BOOST_FACTOR, "1")); }
private void readNumHitsSpecification(Query query) throws ParameterException { //example numHitsSpecification: "music:10,movies:20" String numHitsSpecification = query.properties().getString(numHits); if (numHitsSpecification == null) return; String[] numHitsForDocumentNames = numHitsSpecification.split(","); for (String s:numHitsForDocumentNames) { handleDocumentNameWithNumberOfHits(s); } }
private void readAdditionalHitsFactor(Query query) throws ParameterException { String additionalHitsFactorStr = query.properties().getString(additionalHitsFactorName); if (additionalHitsFactorStr == null) return; try { additionalHitsFactor = Double.parseDouble(additionalHitsFactorStr); } catch (NumberFormatException e) { throw new ParameterException( "Expected floating point number, got '" + additionalHitsFactorStr + "'."); } }
private Resolver selectResolver(Query query) { String resolverId=query.properties().getString(pageResolverName); if (resolverId==null) return resolverRegistry.defaultResolver(); Resolver resolver=resolverRegistry.getComponent(resolverId); if (resolver==null) throw new IllegalArgumentException("No page template resolver '" + resolverId + "'"); return resolver; }
/** * Implements the deprecated "unique" api for deduplication by using grouping. We create a grouping expression on * the field we wish to dedup on (which must be an attribute). * Total hits is calculated using the new count unique groups functionality. */ @Override public Result search(Query query, Execution execution) { // Determine if we should remove duplicates String unique = query.properties().getString(PARAM_UNIQUE); if (unique == null || unique.trim().isEmpty()) { return execution.search(query); } query.trace("Performing deduping by attribute '" + unique + "'.", true, 3); return dedupe(query, execution, unique); }
private RuleBase resolveRuleBase(Query query) { String ruleBaseName=query.properties().getString(rulesRulebase); if (ruleBaseName==null || ruleBaseName.equals("")) return getDefaultRuleBase(); RuleBase ruleBase=getRuleBase(ruleBaseName); if (ruleBase==null) throw new RuleBaseException("Requested rule base '" + ruleBaseName + "' does not exist"); return ruleBase; }
private WandType resolveWandType(IndexFacts.Session indexFacts, Query query) { Index index = indexFacts.getIndex(fieldName); if (index.isNull()) { throw new IllegalArgumentException("Field '" + fieldName + "' was not found in " + indexFacts); } else { return WandType.create(query.properties().getString(WAND_TYPE, "vespa")); } }
private String getJsonCallback() { Result result = getResult(); if (result != null) { Query query = result.getQuery(); if (query != null) { return query.properties().getString(JSON_CALLBACK, null); } } return null; }
public boolean matches(String term,RuleEvaluation e) { Query query=e.getEvaluation().getQuery(); String value=query.properties().getString(term); if (value==null) return false; e.setValue(value); return true; }
/** * Returns the set of properties set for the source or provider given in the query (if any). * * If the query has not set sourceName or providerName, null will be returned */ public static Properties getSourceProperties(Query query) { String sourceName = query.properties().getString(SOURCENAME); String providerName = query.properties().getString(PROVIDERNAME); if (sourceName == null || providerName == null) return null; Properties sourceProperties = new SubProperties("source." + sourceName, query.properties()); Properties providerProperties = new SubProperties("provider." + providerName, query.properties()); sourceProperties.chain(providerProperties); return sourceProperties; }
@Override public Result search(Query query, Execution execution) { String reqParam = query.properties().getString(PARAM_REQUEST); if (reqParam == null) { return execution.search(query); } List<Continuation> continuations = getContinuations(query.properties().getString(PARAM_CONTINUE)); TimeZone zone = getTimeZone(query.properties().getString(PARAM_TIMEZONE, "utc")); for (GroupingOperation op : GroupingOperation.fromStringAsList(reqParam)) { GroupingRequest grpRequest = GroupingRequest.newInstance(query); grpRequest.setRootOperation(op); grpRequest.setTimeZone(zone); grpRequest.continuations().addAll(continuations); } return execution.search(query); }
private String getStringContents(OperatorNode<ExpressionOperator> operator) { switch (operator.getOperator()) { case LITERAL: return operator.getArgument(0, String.class); case VARREF: Preconditions.checkState(userQuery != null, "properties must be available when trying to fetch user input"); return userQuery.properties().getString(operator.getArgument(0, String.class)); default: throw newUnexpectedArgumentException(operator.getOperator(), ExpressionOperator.LITERAL, ExpressionOperator.VARREF); } }
@Override public Result search(Query query, Execution execution) { String fieldName = query.properties().getString(FIELD); if (fieldName != null) { return search(query, execution, fieldName); } else { if (query.isTraceable(5)) { query.trace("BooleanSearcher: Nothing added to query", false, 5); } } return execution.search(query); }
@Override protected void sendFillRequest(Result result, String summaryClass) { ListMap<Integer, FastHit> hitsByNode = hitsByNode(result); CompressionType compression = CompressionType .valueOf(result.getQuery().properties().getString(RpcResourcePool.dispatchCompression, "LZ4").toUpperCase()); if (result.getQuery().getTraceLevel() >= 3) result.getQuery().trace("Sending " + hitsByNode.size() + " summary fetch RPC requests", 3); responseReceiver = new GetDocsumsResponseReceiver(hitsByNode.size(), resourcePool.compressor(), result); for (Map.Entry<Integer, List<FastHit>> nodeHits : hitsByNode.entrySet()) { sendGetDocsumsRequest(nodeHits.getKey(), nodeHits.getValue(), summaryClass, compression, result, responseReceiver); } }
protected QueryPacket createQueryPacket(String serverId, Query query) { QueryPacket queryPacket = QueryPacket.create(serverId, query); int compressionLimit = query.properties().getInteger(PACKET_COMPRESSION_LIMIT, 0); queryPacket.setCompressionLimit(compressionLimit); if (compressionLimit != 0) queryPacket.setCompressionType(query.properties().getString(PACKET_COMPRESSION_TYPE, "lz4")); return queryPacket; }
/** * Programmatic query transform, add terms from config and the EXTRA_TERM * request property. */ @Override public Result search(Query query, Execution execution) { QueryTree q = query.getModel().getQueryTree(); addAndItem(q, infrastructure.normalize( query.properties().getString(EXTRA_TERM))); for (Demo d : extraTerms) { addAndItem(q, d.term()); } return execution.search(query); }
private int requestSummaries(Result result, String summaryClass) throws InvalidChannelException, ClassCastException, IOException { boolean summaryNeedsQuery = searcher.summaryNeedsQuery(result.getQuery()); if (result.getQuery().getTraceLevel() >= 3) result.getQuery().trace((summaryNeedsQuery ? "Resending " : "Not resending ") + "query during document summary fetching", 3); GetDocSumsPacket docsumsPacket = GetDocSumsPacket.create(result, summaryClass, summaryNeedsQuery); int compressionLimit = result.getQuery().properties().getInteger(FastSearcher.PACKET_COMPRESSION_LIMIT, 0); docsumsPacket.setCompressionLimit(compressionLimit); if (compressionLimit != 0) { docsumsPacket.setCompressionType(result.getQuery().properties().getString(FastSearcher.PACKET_COMPRESSION_TYPE, "lz4")); } boolean couldSend = channel.sendPacket(docsumsPacket); if (!couldSend) throw new IOException("Could not successfully send GetDocSumsPacket."); return docsumsPacket.getNumDocsums() + 1; }