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

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

本文整理了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

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

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

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

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

  1. private List<Query> createQueries(Query query, Set<String> docTypes) {
  2. query.getModel().getQueryTree(); // performance: parse query before cloning such that it is only done once
  3. List<Query> retval = new ArrayList<>(docTypes.size());
  4. if (docTypes.size() == 1) {
  5. query.getModel().setRestrict(docTypes.iterator().next());
  6. retval.add(query);
  7. } else if ( ! docTypes.isEmpty() ) {
  8. for (String docType : docTypes) {
  9. Query q = query.clone();
  10. q.setOffset(0);
  11. q.setHits(query.getOffset() + query.getHits());
  12. q.getModel().setRestrict(docType);
  13. retval.add(q);
  14. }
  15. }
  16. return retval;
  17. }

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

  1. public Optional<SearchInvoker> getSearchInvoker(Query query, FS4InvokerFactory fs4InvokerFactory) {
  2. if (multilevelDispatch || ! query.properties().getBoolean(dispatchInternal, internalDispatchByDefault)) {
  3. return Optional.empty();
  4. }
  5. Optional<SearchInvoker> invoker = getSearchPathInvoker(query, fs4InvokerFactory::getSearchInvoker);
  6. if (!invoker.isPresent()) {
  7. invoker = getInternalInvoker(query, fs4InvokerFactory::getSearchInvoker);
  8. }
  9. if (invoker.isPresent() && query.properties().getBoolean(com.yahoo.search.query.Model.ESTIMATE)) {
  10. query.setHits(0);
  11. query.setOffset(0);
  12. }
  13. return invoker;
  14. }

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

  1. /**
  2. * Sends search queries to the contained {@link SearchInvoker} sub-invokers. If the search
  3. * query has an offset other than zero, it will be reset to zero and the expected hit amount
  4. * will be adjusted accordingly.
  5. */
  6. @Override
  7. protected void sendSearchRequest(Query query, QueryPacket queryPacket) throws IOException {
  8. this.query = query;
  9. invokers.forEach(invoker -> invoker.setMonitor(this));
  10. deadline = currentTime() + query.getTimeLeft();
  11. int originalHits = query.getHits();
  12. int originalOffset = query.getOffset();
  13. query.setHits(query.getHits() + query.getOffset());
  14. query.setOffset(0);
  15. trimResult = originalHits != query.getHits() || originalOffset != query.getOffset();
  16. for (SearchInvoker invoker : invokers) {
  17. invoker.sendSearchRequest(query, null);
  18. askedNodes++;
  19. }
  20. query.setHits(originalHits);
  21. query.setOffset(originalOffset);
  22. }

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

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

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

  1. sorting));
  2. query.setHits(0);
  3. query.setOffset(0);
  4. Result result = execution.search(query);
  5. query.setHits(hits);
  6. query.setOffset(offset);

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

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

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

  1. private void copyPropertiesTo(Query clone) {
  2. clone.model = model.cloneFor(clone);
  3. clone.select = select.cloneFor(clone);
  4. clone.ranking = (Ranking) ranking.clone();
  5. clone.presentation = (Presentation) presentation.clone();
  6. clone.context = getContext(true).cloneFor(clone);
  7. // Correct the Query instance in properties
  8. clone.properties().setParentQuery(clone);
  9. assert (clone.properties().getParentQuery() == clone);
  10. clone.setTraceLevel(getTraceLevel());
  11. clone.setHits(getHits());
  12. clone.setOffset(getOffset());
  13. clone.setNoCache(getNoCache());
  14. clone.setGroupingSessionCache(getGroupingSessionCache());
  15. clone.requestId = null; // Each clone should have their own requestId.
  16. }

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

  1. query.setHits(parser.getHits());

相关文章