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

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

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

Query.setHits介绍

[英]Sets the number of hits requested. If hits is less than 0, an IllegalArgumentException is thrown. Default number of hits is 10.
[中]设置请求的点击次数。如果命中数小于0,则抛出IllegalArgumentException。默认点击数为10。

代码示例

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

/** Convenience method to set both the offset and the number of hits to return */
public void setWindow(int offset,int hits) {
  setOffset(offset);
  setHits(hits);
}

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

private Result search(Query query, Execution execution, int offset , int hits) {
  query.setOffset(offset);
  query.setHits(hits);
  return execution.search(query);
}

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

private List<Query> createQueries(Query query, Set<String> docTypes) {
  query.getModel().getQueryTree(); // performance: parse query before cloning such that it is only done once
  List<Query> retval = new ArrayList<>(docTypes.size());
  if (docTypes.size() == 1) {
    query.getModel().setRestrict(docTypes.iterator().next());
    retval.add(query);
  } else if ( ! docTypes.isEmpty() ) {
    for (String docType : docTypes) {
      Query q = query.clone();
      q.setOffset(0);
      q.setHits(query.getOffset() + query.getHits());
      q.getModel().setRestrict(docType);
      retval.add(q);
    }
  }
  return retval;
}

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

public Optional<SearchInvoker> getSearchInvoker(Query query, FS4InvokerFactory fs4InvokerFactory) {
  if (multilevelDispatch || ! query.properties().getBoolean(dispatchInternal, internalDispatchByDefault)) {
    return Optional.empty();
  }
  Optional<SearchInvoker> invoker = getSearchPathInvoker(query, fs4InvokerFactory::getSearchInvoker);
  if (!invoker.isPresent()) {
    invoker = getInternalInvoker(query, fs4InvokerFactory::getSearchInvoker);
  }
  if (invoker.isPresent() && query.properties().getBoolean(com.yahoo.search.query.Model.ESTIMATE)) {
    query.setHits(0);
    query.setOffset(0);
  }
  return invoker;
}

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

/**
 * Sends search queries to the contained {@link SearchInvoker} sub-invokers. If the search
 * query has an offset other than zero, it will be reset to zero and the expected hit amount
 * will be adjusted accordingly.
 */
@Override
protected void sendSearchRequest(Query query, QueryPacket queryPacket) throws IOException {
  this.query = query;
  invokers.forEach(invoker -> invoker.setMonitor(this));
  deadline = currentTime() + query.getTimeLeft();
  int originalHits = query.getHits();
  int originalOffset = query.getOffset();
  query.setHits(query.getHits() + query.getOffset());
  query.setOffset(0);
  trimResult = originalHits != query.getHits() || originalOffset != query.getOffset();
  for (SearchInvoker invoker : invokers) {
    invoker.sendSearchRequest(query, null);
    askedNodes++;
  }
  query.setHits(originalHits);
  query.setOffset(originalOffset);
}

代码示例来源:origin: vespa-engine/sample-apps

private Hit retrieveUserProfile(String userId, Execution execution) {
  Query query = new Query();
  query.getModel().setRestrict("user");
  query.getModel().getQueryTree().setRoot(new WordItem(userId, "user_id"));
  query.setHits(1);
  SearchChain vespaChain = execution.searchChainRegistry().getComponent("vespa");
  Result result = new Execution(vespaChain, execution.context()).search(query);
  execution.fill(result); // This is needed to get the actual summary data
  Iterator<Hit> hiterator = result.hits().deepIterator();
  return hiterator.hasNext() ? hiterator.next() : null;
}

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

sorting));
query.setHits(0);
query.setOffset(0);
Result result = execution.search(query);
query.setHits(hits);
query.setOffset(offset);

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

} else if (key.size()==1) {
  if (key.equals(Query.HITS))
    query.setHits(asInteger(value,10));
  else if (key.equals(Query.OFFSET))
    query.setOffset(asInteger(value,0));

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

private void copyPropertiesTo(Query clone) {
  clone.model = model.cloneFor(clone);
  clone.select = select.cloneFor(clone);
  clone.ranking = (Ranking) ranking.clone();
  clone.presentation = (Presentation) presentation.clone();
  clone.context = getContext(true).cloneFor(clone);
  // Correct the Query instance in properties
  clone.properties().setParentQuery(clone);
  assert (clone.properties().getParentQuery() == clone);
  clone.setTraceLevel(getTraceLevel());
  clone.setHits(getHits());
  clone.setOffset(getOffset());
  clone.setNoCache(getNoCache());
  clone.setGroupingSessionCache(getGroupingSessionCache());
  clone.requestId = null; // Each clone should have their own requestId.
}

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

query.setHits(parser.getHits());

相关文章