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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. /**
  2. * Collapses all single-child {@link CompositeItem}s into their parent item.
  3. */
  4. public static void collapseSingleComposites(Query query) {
  5. Item oldRoot = query.getModel().getQueryTree().getRoot();
  6. Item newRoot = collapseSingleComposites(oldRoot);
  7. if (oldRoot != newRoot) {
  8. query.getModel().getQueryTree().setRoot(newRoot);
  9. }
  10. }

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

  1. /**
  2. * Replaces and {@link SimpleIndexedItem} searching in the {@link Hit#SDDOCNAME_FIELD} with an item
  3. * appropriate for the search node.
  4. */
  5. public static void rewriteSddocname(Query query) {
  6. Item oldRoot = query.getModel().getQueryTree().getRoot();
  7. Item newRoot = rewriteSddocname(oldRoot);
  8. if (oldRoot != newRoot) {
  9. query.getModel().getQueryTree().setRoot(newRoot);
  10. }
  11. }

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

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

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

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

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

  1. private Item replaceTerms(Query q, IndexFacts.Session indexFacts) {
  2. Language language = q.getModel().getParsingLanguage();
  3. if (language == Language.UNKNOWN) {
  4. return q.getModel().getQueryTree().getRoot();
  5. }
  6. StemContext context = new StemContext();
  7. context.isCJK = language.isCjk();
  8. context.language = language;
  9. context.indexFacts = indexFacts;
  10. context.reverseConnectivity = createReverseConnectivities(q.getModel().getQueryTree().getRoot());
  11. return scan(q.getModel().getQueryTree().getRoot(), context);
  12. }

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

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

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

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

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

  1. @Override
  2. public String getEncoding() {
  3. if (getResult() == null
  4. || getResult().getQuery() == null
  5. || getResult().getQuery().getModel().getEncoding() == null) {
  6. return DEFAULT_ENCODING;
  7. } else {
  8. return getResult().getQuery().getModel().getEncoding();
  9. }
  10. }

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

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

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

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

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

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

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

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

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

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

相关文章