com.psddev.dari.db.Query.sortRelevant()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(226)

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

Query.sortRelevant介绍

[英]Adds a sorter that prioritizes the items matching the given predicate.
[中]添加一个排序器,对匹配给定谓词的项进行优先级排序。

代码示例

代码示例来源:origin: perfectsense/dari

/** @deprecated Use {@link #sortRelevant(int, Predicate)} instead. */
@Deprecated
public Query<E> sortRelevant(int weight, Predicate predicate) {
  return sortRelevant((double) weight, predicate);
}

代码示例来源:origin: perfectsense/dari

/**
 * Adds a sorter that prioritizes the items matching the given
 * {@link PredicateParser.Static#parse predicateString}.
 */
public Query<E> sortRelevant(double weight, String predicateString, Object... parameters) {
  return sortRelevant(weight, PredicateParser.Static.parse(predicateString, parameters));
}

代码示例来源:origin: perfectsense/brightspot-cms

@Override
  public void apply(SearchQueryBuilder queryBuilder, Query query, List<String> queryTerms) {
    query.sortRelevant(getBoost(), "_type = ?", type);
  }
}

代码示例来源:origin: perfectsense/dari

/** @deprecated Use {@link #sortRelevant(int, String, Object...)} instead. */
@Deprecated
public Query<E> sortRelevant(int weight, String predicateString, Object... parameters) {
  return sortRelevant((double) weight, PredicateParser.Static.parse(predicateString, parameters));
}

代码示例来源:origin: perfectsense/brightspot-cms

@Override
public void apply(SearchQueryBuilder queryBuilder, Query query, List<String> queryTerms) {
  StringBuilder queryTermsString = new StringBuilder();
  for (String term : queryTerms) {
    queryTermsString.append(term);
    queryTermsString.append(' ');
  }
  Pattern pattern = Pattern.compile(getPattern(), Pattern.CANON_EQ | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
  Matcher matcher = pattern.matcher(queryTermsString.toString());
  while (matcher.find()) {
    int groupCount = matcher.groupCount();
    Object[] parameters = new Object[groupCount];
    for (int i = 0; i < groupCount; ++i) {
      parameters[i] = matcher.group(i + 1);
    }
    Predicate predicate = PredicateParser.Static.parse(getPredicate(), parameters);
    predicate = addPrefix(getType().getInternalName() + "/", predicate);
    query.sortRelevant(getBoost(), predicate);
  }
}

代码示例来源:origin: perfectsense/brightspot-cms

@Override
  public void apply(SearchQueryBuilder queryBuilder, Query query, List<String> queryTerms) {
    double boost = getBoost();
    String prefix = getType().getInternalName() + "/";
    for (String field : getFields()) {
      List<UUID> uuids = new ArrayList<UUID>();
      List<String> texts = new ArrayList<String>();
      if (queryTerms != null) {
        for (String queryTerm : queryTerms) {
          UUID uuid = ObjectUtils.to(UUID.class, queryTerm);
          if (uuid != null) {
            uuids.add(uuid);
          } else {
            texts.add(queryTerm);
          }
        }
      }
      if (type.getField(field) != null && ObjectField.RECORD_TYPE.equals(type.getField(field).getInternalItemType())) {
        if (!uuids.isEmpty()) {
          query.sortRelevant(boost, prefix + field + " matchesAny ?", uuids);
        }
      } else {
        if (!texts.isEmpty()) {
          query.sortRelevant(boost, prefix + field + " matchesAny ?", texts);
        }
      }
    }
  }
}

代码示例来源:origin: perfectsense/brightspot-cms

.sortRelevant(100.0, "_id = ?", mainObjectId);
  query.sortRelevant(100.0, "_label = ?", queryString);
  query.sortRelevant(10.0, "_label matches ?", queryString);
      query.sortRelevant(20.0, "_type = ?", t.as(ToolUi.class).findDisplayTypes());
query.sortRelevant(10.0, "_type = ?", environment.getTypeByClass(Singleton.class).as(ToolUi.class).findDisplayTypes());

相关文章