本文整理了Java中org.apache.lucene.search.BooleanQuery.getMaxClauseCount()
方法的一些代码示例,展示了BooleanQuery.getMaxClauseCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BooleanQuery.getMaxClauseCount()
方法的具体详情如下:
包路径:org.apache.lucene.search.BooleanQuery
类名称:BooleanQuery
方法名:getMaxClauseCount
[英]Return the maximum number of clauses permitted, 1024 by default. Attempts to add more than the permitted number of clauses cause TooManyClauses to be thrown.
[中]返回允许的最大子句数,默认为1024。尝试添加超过允许数量的子句会导致抛出ToomanyClause。
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
protected int getMaxSize() {
return BooleanQuery.getMaxClauseCount();
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
protected int getMaxSize() {
return BooleanQuery.getMaxClauseCount();
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
protected int getMaxSize() {
return BooleanQuery.getMaxClauseCount();
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
protected void checkMaxClauseCount(int count) {
if (count > BooleanQuery.getMaxClauseCount())
throw new BooleanQuery.TooManyClauses();
}
};
代码示例来源:origin: org.apache.lucene/lucene-core
/**
* Creates a new SynonymQuery, matching any of the supplied terms.
* <p>
* The terms must all have the same field.
*/
public SynonymQuery(Term... terms) {
this.terms = Objects.requireNonNull(terms).clone();
// check that all terms are the same field
String field = null;
for (Term term : terms) {
if (field == null) {
field = term.field();
} else if (!term.field().equals(field)) {
throw new IllegalArgumentException("Synonyms must be across the same field");
}
}
if (terms.length > BooleanQuery.getMaxClauseCount()) {
throw new BooleanQuery.TooManyClauses();
}
Arrays.sort(this.terms);
}
代码示例来源:origin: org.apache.lucene/lucene-core
/** Try to collect terms from the given terms enum and return true iff all
* terms could be collected. If {@code false} is returned, the enum is
* left positioned on the next term. */
private boolean collectTerms(LeafReaderContext context, TermsEnum termsEnum, List<TermAndState> terms) throws IOException {
final int threshold = Math.min(BOOLEAN_REWRITE_TERM_COUNT_THRESHOLD, BooleanQuery.getMaxClauseCount());
for (int i = 0; i < threshold; ++i) {
final BytesRef term = termsEnum.next();
if (term == null) {
return true;
}
TermState state = termsEnum.termState();
terms.add(new TermAndState(BytesRef.deepCopyOf(term), state, termsEnum.docFreq(), termsEnum.totalTermFreq()));
}
return termsEnum.next() == null;
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public Query rewrite(IndexReader reader) throws IOException {
final int threshold = Math.min(BOOLEAN_REWRITE_TERM_COUNT_THRESHOLD, BooleanQuery.getMaxClauseCount());
if (termData.size() <= threshold) {
BooleanQuery.Builder bq = new BooleanQuery.Builder();
TermIterator iterator = termData.iterator();
for (BytesRef term = iterator.next(); term != null; term = iterator.next()) {
bq.add(new TermQuery(new Term(iterator.field(), BytesRef.deepCopyOf(term))), Occur.SHOULD);
}
return new ConstantScoreQuery(bq.build());
}
return super.rewrite(reader);
}
代码示例来源:origin: org.apache.lucene/lucene-core
/**
* Expert: Add a {@link Term} with the provided boost and context.
* This method is useful if you already have a {@link TermContext}
* object constructed for the given term.
*/
public Builder add(Term term, float boost, TermContext context) {
if (numTerms >= BooleanQuery.getMaxClauseCount()) {
throw new BooleanQuery.TooManyClauses();
}
terms = ArrayUtil.grow(terms, numTerms + 1);
boosts = ArrayUtil.grow(boosts, numTerms + 1);
contexts = ArrayUtil.grow(contexts, numTerms + 1);
terms[numTerms] = term;
boosts[numTerms] = boost;
contexts[numTerms] = context;
numTerms += 1;
return this;
}
代码示例来源:origin: org.apache.lucene/lucene-core
int[] articulationPoints = graph.articulationPoints();
int lastState = 0;
int maxClauseCount = BooleanQuery.getMaxClauseCount();
for (int i = 0; i <= articulationPoints.length; i++) {
int start = lastState;
代码示例来源:origin: org.elasticsearch/elasticsearch
TopTermSpanBooleanQueryRewriteWithMaxClause() {
this.maxExpansions = BooleanQuery.getMaxClauseCount();
}
代码示例来源:origin: org.apache.lucene/lucene-core
final int threshold = Math.min(BOOLEAN_REWRITE_TERM_COUNT_THRESHOLD, BooleanQuery.getMaxClauseCount());
assert termData.size() > threshold : "Query should have been rewritten";
List<TermAndState> matchingTerms = new ArrayList<>(threshold);
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected void checkMaxClauseCount(int count) {
if (count > maxExpansions) {
throw new RuntimeException("[" + query.toString() + " ] " +
"exceeds maxClauseCount [ Boolean maxClauseCount is set to " + BooleanQuery.getMaxClauseCount() + "]");
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected Query doToQuery(QueryShardContext context) {
if (values.isEmpty()) {
return Queries.newMatchNoDocsQuery("No terms supplied for \"" + getName() + "\" query.");
}
// Fail before we attempt to create the term queries:
if (values.size() > BooleanQuery.getMaxClauseCount()) {
throw new BooleanQuery.TooManyClauses();
}
List<Query> queries = createTermQueries(context);
LongValuesSource longValuesSource = createValuesSource(context);
return new CoveringQuery(queries, longValuesSource);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public Query rewrite(IndexReader reader) throws IOException {
final int threshold = Math.min(BOOLEAN_REWRITE_TERM_COUNT_THRESHOLD, BooleanQuery.getMaxClauseCount());
if (types.length <= threshold) {
Set<BytesRef> uniqueTypes = new HashSet<>();
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene
@Override
protected void checkMaxClauseCount(int count) {
if (count > BooleanQuery.getMaxClauseCount())
throw new BooleanQuery.TooManyClauses();
}
};
代码示例来源:origin: org.infinispan/infinispan-embedded-query
@Override
protected void checkMaxClauseCount(int count) {
if (count > BooleanQuery.getMaxClauseCount())
throw new BooleanQuery.TooManyClauses();
}
};
代码示例来源:origin: rdelbru/SIREn
@Override
protected void checkMaxClauseCount(final int count) {
if (count > BooleanQuery.getMaxClauseCount())
throw new BooleanQuery.TooManyClauses();
}
代码示例来源:origin: org.apache.jackrabbit/oak-lucene
private void configureBooleanClauseLimit(Map<String, ?> config) {
int booleanClauseLimit = PropertiesUtil.toInteger(config.get(PROP_BOOLEAN_CLAUSE_LIMIT),
PROP_BOOLEAN_CLAUSE_LIMIT_DEFAULT);
if (booleanClauseLimit != BooleanQuery.getMaxClauseCount()){
BooleanQuery.setMaxClauseCount(booleanClauseLimit);
log.info("Changed the Max boolean clause limit to {}", booleanClauseLimit);
}
}
代码示例来源:origin: com.atlassian.jira/jira-core
private static void assertClauseNotTooComplex(final Clause clause)
{
if (clause.getClauses().size() > BooleanQuery.getMaxClauseCount())
{
throw new JqlTooComplex(clause);
}
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void booleanQuerySize() throws Exception{
Map<String,Object> config = getDefaultConfig();
config.put("booleanClauseLimit", 4000);
MockOsgi.activate(service, context.bundleContext(), config);
assertEquals(4000, BooleanQuery.getMaxClauseCount());
}
内容来源于网络,如有侵权,请联系作者删除!