org.apache.lucene.search.BooleanQuery.setMinimumNumberShouldMatch()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(119)

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

BooleanQuery.setMinimumNumberShouldMatch介绍

[英]Set the minimum number of matching SHOULD clauses.
[中]设置匹配的SHOULD子句的最小数目。

代码示例

代码示例来源:origin: apache/nifi

private BooleanQuery buildLineageQuery(final Collection<String> flowFileUuids) {
  // Create a query for all Events related to the FlowFiles of interest. We do this by adding all ID's as
  // "SHOULD" clauses and then setting the minimum required to 1.
  final BooleanQuery lineageQuery;
  if (flowFileUuids == null || flowFileUuids.isEmpty()) {
    lineageQuery = null;
  } else {
    lineageQuery = new BooleanQuery();
    for (final String flowFileUuid : flowFileUuids) {
      lineageQuery.add(new TermQuery(new Term(SearchableFields.FlowFileUUID.getSearchableFieldName(), flowFileUuid)), Occur.SHOULD);
    }
    lineageQuery.setMinimumNumberShouldMatch(1);
  }
  return lineageQuery;
}

代码示例来源:origin: apache/nifi

flowFileIdQuery.add(new TermQuery(new Term(SearchableFields.FlowFileUUID.getSearchableFieldName(), flowFileUuid)), Occur.SHOULD);
flowFileIdQuery.setMinimumNumberShouldMatch(1);

代码示例来源:origin: org.compass-project/compass

public SearchEngineQueryBuilder.SearchEngineBooleanQueryBuilder setMinimumNumberShouldMatch(int min) {
  boolQuery.setMinimumNumberShouldMatch(min);
  return this;
}

代码示例来源:origin: com.senseidb/sensei-core

if (!AND_PARAM.equals(op)) query.setMinimumNumberShouldMatch(minimum_match);

代码示例来源:origin: jenkins-infra/update-center2

public Collection<PluginHistory> listHudsonPlugins() throws PlexusContainerException, ComponentLookupException, IOException, UnsupportedExistingLuceneIndexException, AbstractArtifactResolutionException {
  BooleanQuery q = new BooleanQuery();
  q.setMinimumNumberShouldMatch(1);
  q.add(indexer.constructQuery(ArtifactInfo.PACKAGING,"hpi"), Occur.SHOULD);
  q.add(indexer.constructQuery(ArtifactInfo.PACKAGING,"jpi"), Occur.SHOULD);

代码示例来源:origin: org.compass-project/compass

/**
 * If enabled and allowed, wraps the given query with a boolean query that adds a must match on the alias).
 */
public static Query andAliasQueryIfNeeded(Query query, ResourcePropertyLookup lookup, boolean addAliasQueryWithDotPath,
                     SearchEngineFactory searchEngineFactory) {
  if (query == null) {
    return query;
  }
  if (!addAliasQueryWithDotPath) {
    return query;
  }
  if (lookup == null) {
    return query;
  }
  String alias = lookup.getDotPathAlias();
  if (alias == null) {
    return query;
  }
  BooleanQuery booleanQuery = new BooleanQuery();
  booleanQuery.add(query, BooleanClause.Occur.MUST);
  BooleanQuery aliasQuery = new BooleanQuery();
  aliasQuery.add(new TermQuery(new Term(searchEngineFactory.getAliasProperty(), alias)), BooleanClause.Occur.SHOULD);
  aliasQuery.add(new TermQuery(new Term(searchEngineFactory.getExtendedAliasProperty(), alias)), BooleanClause.Occur.SHOULD);
  aliasQuery.setMinimumNumberShouldMatch(1);
  booleanQuery.add(aliasQuery, BooleanClause.Occur.MUST);
  return booleanQuery;
}

代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core

q.setMinimumNumberShouldMatch(msm);

代码示例来源:origin: com.senseidb/sensei-core

BooleanClause.Occur.SHOULD);
query.setMinimumNumberShouldMatch(jsonQuery.optInt(MINIMUM_NUMBER_SHOULD_MATCH_PARAM, 0));

代码示例来源:origin: apache/jackrabbit-oak

builder.setMinimumNumberShouldMatch((int) (Math.ceil(minhashes.size() * similarity)));

代码示例来源:origin: org.apache.jackrabbit/oak-lucene

builder.setMinimumNumberShouldMatch((int) (Math.ceil(minhashes.size() * similarity)));

代码示例来源:origin: sirensolutions/siren

public BooleanQuery build(QueryNode queryNode) throws QueryNodeException {
 AnyQueryNode andNode = (AnyQueryNode) queryNode;
 BooleanQuery bQuery = new BooleanQuery();
 List<QueryNode> children = andNode.getChildren();
 if (children != null) {
  for (QueryNode child : children) {
   Object obj = child.getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
   if (obj != null) {
    Query query = (Query) obj;
    try {
     bQuery.add(query, BooleanClause.Occur.SHOULD);
    } catch (TooManyClauses ex) {
     throw new QueryNodeException(new MessageImpl(
     /*
      * IQQQ.Q0028E_TOO_MANY_BOOLEAN_CLAUSES,
      * BooleanQuery.getMaxClauseCount()
      */
      QueryParserMessages.EMPTY_MESSAGE), ex);
    }
   }
  }
 }
 bQuery.setMinimumNumberShouldMatch(andNode.getMinimumMatchingElements());
 return bQuery;
}

代码示例来源:origin: rdelbru/SIREn

public BooleanQuery build(QueryNode queryNode) throws QueryNodeException {
 AnyQueryNode andNode = (AnyQueryNode) queryNode;
 BooleanQuery bQuery = new BooleanQuery();
 List<QueryNode> children = andNode.getChildren();
 if (children != null) {
  for (QueryNode child : children) {
   Object obj = child.getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
   if (obj != null) {
    Query query = (Query) obj;
    try {
     bQuery.add(query, BooleanClause.Occur.SHOULD);
    } catch (TooManyClauses ex) {
     throw new QueryNodeException(new MessageImpl(
     /*
      * IQQQ.Q0028E_TOO_MANY_BOOLEAN_CLAUSES,
      * BooleanQuery.getMaxClauseCount()
      */
      QueryParserMessages.EMPTY_MESSAGE), ex);
    }
   }
  }
 }
 bQuery.setMinimumNumberShouldMatch(andNode.getMinimumMatchingElements());
 return bQuery;
}

代码示例来源:origin: com.atlassian.jira/jira-core

final BooleanQuery originalQuery = queryBucket.getOriginalBooleanQuery();
query.setBoost(originalQuery.getBoost());
query.setMinimumNumberShouldMatch(originalQuery.getMinimumNumberShouldMatch());
    notWithMatchAll.setMinimumNumberShouldMatch(((BooleanQuery)notQuery).getMinimumNumberShouldMatch());
    ((BooleanQuery)notQuery).setMinimumNumberShouldMatch(0);
    notWithMatchAll.add(transformBooleanQuery((BooleanQuery) notQuery), BooleanClause.Occur.MUST_NOT);

代码示例来源:origin: io.hawt/hawtio-maven-indexer

@Override
public List<ArtifactDTO> searchTextAndPackaging(String searchText, String packaging, String classifier) throws IOException {
  BooleanQuery bq = new BooleanQuery();
  if (StringUtils.isNotBlank(searchText)) {
    BooleanQuery textQuery = createTextSearchQuery(searchText);
    textQuery.setMinimumNumberShouldMatch(1);
    bq.add(textQuery, Occur.MUST);
  }
  if (StringUtils.isNotBlank(packaging)) {
    bq.add(indexer.constructQuery(MAVEN.PACKAGING, new SourcedSearchExpression(packaging)), Occur.MUST);
  }
  if (StringUtils.isNotBlank(classifier)) {
    bq.add(indexer.constructQuery(MAVEN.CLASSIFIER, new SourcedSearchExpression(classifier)), Occur.MUST);
  }
  return searchGrouped(bq);
}

代码示例来源:origin: com.atlassian.jira/jira-core

private BooleanQuery handleContainsMust(final QueryBucket queryBucket)
{
  BooleanQuery query = new BooleanQuery();
  // There is nothing to do here except complete a deep dive on each query
  final BooleanQuery originalBooleanQuery = queryBucket.getOriginalBooleanQuery();
  query.setBoost(originalBooleanQuery.getBoost());
  query.setMinimumNumberShouldMatch(originalBooleanQuery.getMinimumNumberShouldMatch());
  final BooleanClause[] booleanClauses = originalBooleanQuery.getClauses();
  for (BooleanClause booleanClause : booleanClauses)
  {
    final Query subQuery = booleanClause.getQuery();
    final BooleanClause.Occur subOccur = booleanClause.getOccur();
    if (subQuery instanceof BooleanQuery)
    {
      query.add(transformBooleanQuery((BooleanQuery) subQuery), subOccur);
    }
    else
    {
      query.add((Query) subQuery.clone(), subOccur);
    }
  }
  return query;
}

代码示例来源:origin: com.atlassian.jira/jira-core

private BooleanQuery handleOnlyNot(final QueryBucket queryBucket)
{
  BooleanQuery query = new BooleanQuery();
  BooleanQuery originalQuery = queryBucket.getOriginalBooleanQuery();
  query.setBoost(originalQuery.getBoost());
  query.setMinimumNumberShouldMatch(originalQuery.getMinimumNumberShouldMatch());
  // We always add a match all in this case
  query.add(new MatchAllDocsQuery(), BooleanClause.Occur.MUST);
  for (Query origNotQuery : queryBucket.getNotQueries())
  {
    Query notQuery = (Query) origNotQuery.clone();
    // Make sure we continue to dive the tree if we need to
    if (notQuery instanceof BooleanQuery)
    {
      query.add(transformBooleanQuery((BooleanQuery) notQuery), BooleanClause.Occur.MUST_NOT);
    }
    else
    {
      query.add(notQuery, BooleanClause.Occur.MUST_NOT);
    }
  }
  return query;
}

代码示例来源:origin: org.compass-project/compass

BooleanQuery replaced = new BooleanQuery(original.isCoordDisabled());
replaced.setBoost(original.getBoost());
replaced.setMinimumNumberShouldMatch(original.getMinimumNumberShouldMatch());
for (BooleanClause clause : original.getClauses()) {
  replaced.add(visit(clause.getQuery(), visitor), clause.getOccur());

代码示例来源:origin: ajermakovics/eclipse-instasearch

newBoolQuery.setMinimumNumberShouldMatch(boolQuery.getMinimumNumberShouldMatch());

相关文章