com.yahoo.search.Query.properties()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(240)

本文整理了Java中com.yahoo.search.Query.properties方法的一些代码示例,展示了Query.properties的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.properties方法的具体详情如下:
包路径:com.yahoo.search.Query
类名称:Query
方法名:properties

Query.properties介绍

[英]Returns the properties of this query. The properties are modifiable
[中]返回此查询的属性。属性是可修改的

代码示例

代码示例来源:origin: com.yahoo.vespa/container-search

/** Returns the intent model stored at property key "intentModel" in this query, or null if none */
public static IntentModel getFrom(Query query) {
  return (IntentModel)query.properties().get(intentModelObjectName);
}

代码示例来源:origin: com.yahoo.vespa/container-search

/**
 * Sets the list of {@link Grouping} objects assigned to the given query. This method overwrites any grouping
 * objects already assigned to the query.
 *
 * @param query The query whose grouping list to set.
 * @param lst   The grouping list to set.
 */
public static void setGroupingList(Query query, List<Grouping> lst) {
  query.properties().set(PROP_GROUPINGLIST, lst);
}

代码示例来源:origin: com.yahoo.vespa/container-search

public static boolean hasGroupingList(Query query) {
  Object obj = query.properties().get(PROP_GROUPINGLIST);
  return (obj instanceof List);
}

代码示例来源:origin: com.yahoo.vespa/container-search

/**
 * Returns the number of milliseconds to wait for a response from a search backend
 * before timing it out. Default is 500.
 * <p>
 * Note: If Ranking.RANKFEATURES is turned on, this is hardcoded to 6 minutes.
 *
 * @return timeout in milliseconds.
 */
public long getTimeout() {
  return properties().getBoolean(Ranking.RANKFEATURES, false) ? dumpTimeout : timeout;
}

代码示例来源:origin: com.yahoo.vespa/container-search

static int getQueryFlags(Query query) {
  int flags = QFLAG_EXTENDED_COVERAGE | QFLAG_COVERAGE_NODES;
  flags |= query.properties().getBoolean(com.yahoo.search.query.Model.ESTIMATE) ? QFLAG_ESTIMATE : 0;
  flags |= query.getNoCache() ? QFLAG_NO_RESULTCACHE : 0;
  flags |= query.properties().getBoolean(Ranking.RANKFEATURES, false) ? QFLAG_DUMP_FEATURES : 0;
  return flags;
}

代码示例来源:origin: com.yahoo.vespa/container-search

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);
  }
}

代码示例来源:origin: com.yahoo.vespa/container-search

/** Adds parameters specified in the source to the correct namespace in the query */
private void addParameters(Source source,Query query) {
  for (Map.Entry<String,String> parameter : source.parameters().entrySet())
    query.properties().set("source." + source.getName() + "." + parameter.getKey(),parameter.getValue());
}

代码示例来源:origin: com.yahoo.vespa/container-search

private Query(Query query, long startTime) {
  super(query.properties().clone());
  this.startTime = startTime;
  this.httpRequest = query.httpRequest;
  query.copyPropertiesTo(this);
}

代码示例来源:origin: com.yahoo.vespa/container-search

static int getQueryFlags(Query query) {
  int flags = 0;
  boolean requestCoverage=true; // Always request coverage information
  flags |= 0; // was collapse
  flags |= query.properties().getBoolean(Model.ESTIMATE) ? 0x00000080 : 0;
  flags |= (query.getRanking().getFreshness() != null) ? 0x00002000 : 0;
  flags |= requestCoverage ? 0x00008000 : 0;
  flags |= query.getNoCache() ? 0x00010000 : 0;
  flags |= 0x00020000;                         // was PARALLEL
  flags |= query.properties().getBoolean(Ranking.RANKFEATURES,false) ? 0x00040000 : 0;
  return flags;
}

代码示例来源:origin: com.yahoo.vespa/container-search

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;
}

代码示例来源:origin: com.yahoo.vespa/container-search

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;
}

代码示例来源:origin: com.yahoo.vespa/container-search

/**
 * Pass metadata to the next rewriter through query properties
 *
 * @param query Query object from the searcher
 * @param metadata HashMap containing the metadata
 */
public static void setRewriteMeta(Query query, HashMap<String, Object> metadata) {
  log(utilsLogger, query, "Passing metadata to the next rewriter");
  query.properties().set(RewriterConstants.REWRITE_META, metadata);
  log(utilsLogger, query, "Successfully passed metadata to the next rewriter");
}

代码示例来源:origin: com.yahoo.vespa/container-search

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"));
  }
}

代码示例来源:origin: com.yahoo.vespa/container-search

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;
}

代码示例来源:origin: com.yahoo.vespa/container-search

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;
}

代码示例来源:origin: com.yahoo.vespa/container-search

public Optional<FillInvoker> getFillInvoker(Query query, VespaBackEndSearcher searcher, DocumentDatabase documentDb) {
  if (query.properties().getBoolean(dispatchSummaries, true)
    && ! searcher.summaryNeedsQuery(query)
    && query.getRanking().getLocation() == null
    && ! searcher.getCacheControl().useCache(query))
  {
    return Optional.of(new RpcFillInvoker(this, documentDb));
  } else {
    return Optional.empty();
  }
}

代码示例来源:origin: com.yahoo.vespa/container-search

private void filter(Result result) {
  Set<String> requestedFields;
  if (result.getQuery().properties().getBoolean(FIELD_FILTER_DISABLE)) return;
  if (result.getQuery().getPresentation().getSummaryFields().isEmpty()) return;
  requestedFields = result.getQuery().getPresentation().getSummaryFields();
  for (Iterator<Hit> i = result.hits().unorderedDeepIterator(); i.hasNext();) {
    Hit h = i.next();
    if (h.isMeta()) continue;
    h.fieldKeys().retainAll(requestedFields);
  }
}

代码示例来源:origin: com.yahoo.vespa/container-search

@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);
}

代码示例来源:origin: com.yahoo.vespa/container-search

@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);
  }
}

代码示例来源:origin: com.yahoo.vespa/container-search

private boolean shouldBeDegraded(Query query, IndexFacts.Session indexFacts) {
  if (query.getRanking().getSorting() == null) return false;
  if (query.getRanking().getSorting().fieldOrders().isEmpty()) return false;
  if ( ! query.getSelect().getGrouping().isEmpty()) return false;
  if ( ! query.properties().getBoolean(DEGRADING, true)) return false;
  Index index = indexFacts.getIndex(query.getRanking().getSorting().fieldOrders().get(0).getFieldName());
  if (index == null) return false;
  if ( ! index.isFastSearch()) return false;
  if ( ! index.isNumerical()) return false;
  return true;
}

相关文章