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

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

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

Query.getModel介绍

[英]Returns the query representation model to be used for this query, never null
[中]返回用于此查询的查询表示模型,从不为null

代码示例

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

/**
 * Sets the document selection criterion of the query.
 *
 * @param where the documents to select as a JSON string on the format specified in
 *        <a href="https://docs.vespa.ai/documentation/reference/select-reference.html">the select reference doc</a>
 */
public void setWhereString(String where) {
  this.where = where;
  parent.getModel().setType(SELECT);
  // This replaces the current query
  parent.getModel().clearQueryTree();
}

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

/** Calls resolveDocumentTypes(query.getModel().getSources(), query.getModel().getRestrict()) */
private Set<String> resolveDocumentTypes(Query query) {
  // Assumption: Search definition name equals document name.
  return resolveDocumentTypes(query.getModel().getSources(), query.getModel().getRestrict(),
                searchDefinitions.keySet());
}

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

/** Returns the encoding of the query, or the encoding given by the template if none is set */
public final String getRequestedEncoding(Query query) {
  String encoding = query.getModel().getEncoding();
  if (encoding != null) return encoding;
  return getEncoding();
}

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

/** Returns the encoding of the query, or the encoding given by the template if none is set */
public final String getRequestedEncoding(Query query) {
  String encoding = query.getModel().getEncoding();
  if (encoding != null) return encoding;
  return getEncoding();
}

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

@NonNull
private Item fetchUserQuery() {
  Preconditions.checkState(!queryParser, "Tried inserting user query into itself.");
  Preconditions.checkState(userQuery != null,
               "User query must be set before trying to build complete query "
               + "tree including user query.");
  return userQuery.getModel().getQueryTree().getRoot();
}

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

/**
 * Adds a key-value which will be logged to the access log for this query (by doing toString() on the value
 * Multiple values may be set to the same key. A value cannot be removed once set.
 */
public void logValue(String key,Object value) {
  owner.getModel().getExecution().trace().logValue(key, value.toString());
}

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

/** Adds an item to the query being evaluated in a way consistent with the query type */
// TODO: Add this functionality to Query?
public void addItem(Item item, TermType termType) {
  Item root= query.getModel().getQueryTree().getRoot();
  if (root==null)
    query.getModel().getQueryTree().setRoot(item);
  else
    query.getModel().getQueryTree().setRoot(combineItems(root,item,termType));
}

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

/**
 * Collapses all single-child {@link CompositeItem}s into their parent item.
 */
public static void collapseSingleComposites(Query query) {
  Item oldRoot = query.getModel().getQueryTree().getRoot();
  Item newRoot = collapseSingleComposites(oldRoot);
  if (oldRoot != newRoot) {
    query.getModel().getQueryTree().setRoot(newRoot);
  }
}

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

/**
 * Replaces and {@link SimpleIndexedItem} searching in the {@link Hit#SDDOCNAME_FIELD} with an item
 * appropriate for the search node.
 */
public static void rewriteSddocname(Query query) {
  Item oldRoot = query.getModel().getQueryTree().getRoot();
  Item newRoot = rewriteSddocname(oldRoot);
  if (oldRoot != newRoot) {
    query.getModel().getQueryTree().setRoot(newRoot);
  }
}

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

private Result handleError(RuleBase ruleBase,Query query,String error) {
  String message="Evaluation of query '" + query.getModel().getQueryTree() +
          "' over '" + ruleBase + "' caused the invalid query '" +
          query.getModel().getQueryTree().getRoot() + "': " + error;
  getLogger().warning(message);
  return new Result(query,ErrorMessage.createInvalidQueryTransformation(message));
}

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

protected void matchAutomata(Query query,int traceLevel) {
  List<PhraseMatcher.Phrase> matches=getPhraseMatcher().matchPhrases(query.getModel().getQueryTree().getRoot());
  if (matches==null || matches.size()==0) return;
  for (Iterator<PhraseMatcher.Phrase> i=matches.iterator(); i.hasNext(); ) {
    PhraseMatcher.Phrase phrase= i.next();
    if (traceLevel>=3)
       query.trace("Semantic searcher automata matched " + phrase,false,1);
    annotatePhrase(phrase,query,traceLevel);
  }
}

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

private Item replaceTerms(Query q, IndexFacts.Session indexFacts) {
  Language language = q.getModel().getParsingLanguage();
  if (language == Language.UNKNOWN) {
    return q.getModel().getQueryTree().getRoot();
  }
  StemContext context = new StemContext();
  context.isCJK = language.isCjk();
  context.language = language;
  context.indexFacts = indexFacts;
  context.reverseConnectivity = createReverseConnectivities(q.getModel().getQueryTree().getRoot());
  return scan(q.getModel().getQueryTree().getRoot(), context);
}

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

/** Returns a short string description of this (includes the first few messages only, and no newlines) */
@Override
public String toString() {
  return owner.getModel().getExecution().trace().toString();
}

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

@Override
public Result search(Query query, Execution execution) {
  Language language = query.getModel().getParsingLanguage();
  if ( ! language.isCjk()) return execution.search(query);
  QueryTree tree = query.getModel().getQueryTree();
  tree.setRoot(transform(tree.getRoot()));
  query.trace("Rewriting for CJK behavior for implicit phrases", true, 2);
  return execution.search(query);
}

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

@Override
public String getEncoding() {
  if (getResult() == null
    || getResult().getQuery() == null
    || getResult().getQuery().getModel().getEncoding() == null) {
    return DEFAULT_ENCODING;
  } else {
    return getResult().getQuery().getModel().getEncoding();
  }
}

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

/**
 * Prepares this for binary serialization.
 * <p>
 * This must be invoked after all changes have been made to this query before it is passed
 * on to a receiving backend. Calling it is somewhat expensive, so it should only happen once.
 * If a prepared query is cloned, it stays prepared.
 */
public void prepare() {
  getModel().prepare(getRanking());
  getPresentation().prepare();
  getRanking().prepare();
}

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

@Override
public Result search(Query query, Execution execution) {
  if (execution.context().getIndexFacts() == null) return execution.search(query); // this is a test query
  boolean optimized = recursiveOptimize(query.getModel().getQueryTree(), execution.context().getIndexFacts().newSession(query));
  if (optimized)
    query.trace("Optimized query ranges", true, 2);
  return execution.search(query);
}

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

@SuppressWarnings("UnusedParameters")
public void queryContext(XMLWriter writer, QueryContext queryContext, Query owner) throws IOException {
  if (owner.getTraceLevel()!=0) {
    XMLWriter xmlWriter=XMLWriter.from(writer);
    xmlWriter.openTag("meta").attribute("type", QueryContext.ID);
    TraceNode traceRoot = owner.getModel().getExecution().trace().traceNode().root();
    traceRoot.accept(new RenderingVisitor(xmlWriter, owner.getStartTime()));
    xmlWriter.closeTag();
  }
}

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

private void queryContext(XMLWriter writer, Query owner) {
  if (owner.getTraceLevel()!=0) {
    XMLWriter xmlWriter=XMLWriter.from(writer);
    xmlWriter.openTag("meta").attribute("type", QueryContext.ID);
    TraceNode traceRoot = owner.getModel().getExecution().trace().traceNode().root();
    traceRoot.accept(new XmlRenderer.RenderingVisitor(xmlWriter, owner.getStartTime()));
    xmlWriter.closeTag();
  }
}

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

@Override
public Result search(Query query, Execution execution) {
  IndexFacts indexFacts = execution.context().getIndexFacts();
  if ( ! indexFacts.hasNGramIndices()) return execution.search(query); // shortcut
  IndexFacts.Session session = indexFacts.newSession(query);
  boolean rewritten = rewriteToNGramMatching(query.getModel().getQueryTree().getRoot(), 0, session, query);
  if (rewritten)
    query.trace("Rewritten to n-gram matching",true,2);
  Result result = execution.search(query);
  recombineNGrams(result.hits().deepIterator(), session);
  return result;
}

相关文章