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

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

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

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

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

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

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

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

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

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

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

  1. @Override
  2. public void apply(SearchQueryBuilder queryBuilder, Query query, List<String> queryTerms) {
  3. StringBuilder queryTermsString = new StringBuilder();
  4. for (String term : queryTerms) {
  5. queryTermsString.append(term);
  6. queryTermsString.append(' ');
  7. }
  8. Pattern pattern = Pattern.compile(getPattern(), Pattern.CANON_EQ | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
  9. Matcher matcher = pattern.matcher(queryTermsString.toString());
  10. while (matcher.find()) {
  11. int groupCount = matcher.groupCount();
  12. Object[] parameters = new Object[groupCount];
  13. for (int i = 0; i < groupCount; ++i) {
  14. parameters[i] = matcher.group(i + 1);
  15. }
  16. Predicate predicate = PredicateParser.Static.parse(getPredicate(), parameters);
  17. predicate = addPrefix(getType().getInternalName() + "/", predicate);
  18. query.sortRelevant(getBoost(), predicate);
  19. }
  20. }

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

  1. @Override
  2. public void apply(SearchQueryBuilder queryBuilder, Query query, List<String> queryTerms) {
  3. double boost = getBoost();
  4. String prefix = getType().getInternalName() + "/";
  5. for (String field : getFields()) {
  6. List<UUID> uuids = new ArrayList<UUID>();
  7. List<String> texts = new ArrayList<String>();
  8. if (queryTerms != null) {
  9. for (String queryTerm : queryTerms) {
  10. UUID uuid = ObjectUtils.to(UUID.class, queryTerm);
  11. if (uuid != null) {
  12. uuids.add(uuid);
  13. } else {
  14. texts.add(queryTerm);
  15. }
  16. }
  17. }
  18. if (type.getField(field) != null && ObjectField.RECORD_TYPE.equals(type.getField(field).getInternalItemType())) {
  19. if (!uuids.isEmpty()) {
  20. query.sortRelevant(boost, prefix + field + " matchesAny ?", uuids);
  21. }
  22. } else {
  23. if (!texts.isEmpty()) {
  24. query.sortRelevant(boost, prefix + field + " matchesAny ?", texts);
  25. }
  26. }
  27. }
  28. }
  29. }

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

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

相关文章