本文整理了Java中org.apache.lucene.search.Query.clone
方法的一些代码示例,展示了Query.clone
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.clone
方法的具体详情如下:
包路径:org.apache.lucene.search.Query
类名称:Query
方法名:clone
[英]Returns a clone of this query.
[中]返回此查询的克隆。
代码示例来源:origin: org.infinispan/infinispan-embedded-query
@Override
public CustomScoreQuery clone() {
CustomScoreQuery clone = (CustomScoreQuery) super.clone();
clone.subQuery = subQuery;
clone.scoringQueries = new Query[scoringQueries.length];
for(int i = 0; i < scoringQueries.length; i++) {
clone.scoringQueries[i] = scoringQueries[i];
}
return clone;
}
代码示例来源:origin: harbby/presto-connectors
@Override
public CustomScoreQuery clone() {
CustomScoreQuery clone = (CustomScoreQuery) super.clone();
clone.subQuery = subQuery;
clone.scoringQueries = new Query[scoringQueries.length];
for(int i = 0; i < scoringQueries.length; i++) {
clone.scoringQueries[i] = scoringQueries[i];
}
return clone;
}
代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene
/** Create a shallow copy of us -- used in rewriting if necessary
* @return a copy of us (but reuse, don't copy, our subqueries) */
public Object clone() {
DisjunctionMaxQuery clone = (DisjunctionMaxQuery)super.clone();
clone.disjuncts = (ArrayList)this.disjuncts.clone();
return clone;
}
代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene
public Object clone() {
BooleanQuery clone = (BooleanQuery)super.clone();
clone.clauses = (ArrayList)this.clauses.clone();
return clone;
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
@Override
public BooleanQuery clone() {
BooleanQuery clone = (BooleanQuery) super.clone();
clone.clauses = new ArrayList<>(clauses);
return clone;
}
代码示例来源:origin: lucene/lucene
public Object clone() {
BooleanQuery clone = (BooleanQuery)super.clone();
clone.clauses = (Vector)this.clauses.clone();
return clone;
}
代码示例来源:origin: org.apache.lucene/lucene-core-jfrog
public Object clone() {
BooleanQuery clone = (BooleanQuery)super.clone();
clone.clauses = (ArrayList)this.clauses.clone();
return clone;
}
代码示例来源:origin: org.apache.lucene/lucene-core-jfrog
/** Create a shallow copy of us -- used in rewriting if necessary
* @return a copy of us (but reuse, don't copy, our subqueries) */
public Object clone() {
DisjunctionMaxQuery clone = (DisjunctionMaxQuery)super.clone();
clone.disjuncts = (ArrayList)this.disjuncts.clone();
return clone;
}
代码示例来源:origin: harbby/presto-connectors
@Override
public BooleanQuery clone() {
BooleanQuery clone = (BooleanQuery) super.clone();
clone.clauses = new ArrayList<>(clauses);
return clone;
}
代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene
public Object clone() {
CustomScoreQuery clone = (CustomScoreQuery)super.clone();
clone.subQuery = (Query) subQuery.clone();
clone.valSrcQueries = new ValueSourceQuery[valSrcQueries.length];
for(int i = 0; i < valSrcQueries.length; i++) {
clone.valSrcQueries[i] = (ValueSourceQuery) valSrcQueries[i].clone();
}
return clone;
}
代码示例来源:origin: org.apache.lucene/lucene-core-jfrog
public Object clone() {
CustomScoreQuery clone = (CustomScoreQuery)super.clone();
clone.subQuery = (Query) subQuery.clone();
clone.valSrcQueries = new ValueSourceQuery[valSrcQueries.length];
for(int i = 0; i < valSrcQueries.length; i++) {
clone.valSrcQueries[i] = (ValueSourceQuery) valSrcQueries[i].clone();
}
return clone;
}
代码示例来源:origin: harbby/presto-connectors
@Override
public Query clone() {
Query clonedQuery = origParentQuery.clone();
return new IncludeNestedDocsQuery(clonedQuery, this);
}
}
代码示例来源:origin: Cue/greplin-lucene-utils
/**
* Creates a new boosting query.
* @param match the query to match.
* @param context the query to base boosting on.
* @param boost the amount of the boost.
*/
public ConstantQueryNormBoostingQuery(
final Query match, final Query context, final float boost) {
this.match = match;
this.context = (Query) context.clone();
this.boost = boost;
this.context.setBoost(0.0f);
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
/** Expert: called to re-write queries into primitive queries. For example,
* a PrefixQuery will be rewritten into a BooleanQuery that consists
* of TermQuerys.
*/
public Query rewrite(IndexReader reader) throws IOException {
if (boost != 1f) {
Query rewritten = clone();
rewritten.setBoost(1f);
return new BoostQuery(rewritten, boost);
}
return this;
}
代码示例来源:origin: harbby/presto-connectors
/** Expert: called to re-write queries into primitive queries. For example,
* a PrefixQuery will be rewritten into a BooleanQuery that consists
* of TermQuerys.
*/
public Query rewrite(IndexReader reader) throws IOException {
if (boost != 1f) {
Query rewritten = clone();
rewritten.setBoost(1f);
return new BoostQuery(rewritten, boost);
}
return this;
}
代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core
/** Fixes a negative query by adding a MatchAllDocs query clause.
* The query passed in *must* be a negative query.
*/
static Query fixNegativeQuery(Query q) {
BooleanQuery newBq = (BooleanQuery)q.clone();
newBq.add(new MatchAllDocsQuery(), BooleanClause.Occur.MUST);
return newBq;
}
代码示例来源:origin: org.apache.lucene/lucene-core-jfrog
/** Optimize our representation and our subqueries representations
* @param reader the IndexReader we query
* @return an optimized copy of us (which may not be a copy if there is nothing to optimize) */
public Query rewrite(IndexReader reader) throws IOException {
if (disjuncts.size() == 1) {
Query singleton = (Query) disjuncts.get(0);
Query result = singleton.rewrite(reader);
if (getBoost() != 1.0f) {
if (result == singleton) result = (Query)result.clone();
result.setBoost(getBoost() * result.getBoost());
}
return result;
}
DisjunctionMaxQuery clone = null;
for (int i = 0 ; i < disjuncts.size(); i++) {
Query clause = (Query) disjuncts.get(i);
Query rewrite = clause.rewrite(reader);
if (rewrite != clause) {
if (clone == null) clone = (DisjunctionMaxQuery)this.clone();
clone.disjuncts.set(i, rewrite);
}
}
if (clone != null) return clone;
else return this;
}
代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene
/** Optimize our representation and our subqueries representations
* @param reader the IndexReader we query
* @return an optimized copy of us (which may not be a copy if there is nothing to optimize) */
public Query rewrite(IndexReader reader) throws IOException {
if (disjuncts.size() == 1) {
Query singleton = (Query) disjuncts.get(0);
Query result = singleton.rewrite(reader);
if (getBoost() != 1.0f) {
if (result == singleton) result = (Query)result.clone();
result.setBoost(getBoost() * result.getBoost());
}
return result;
}
DisjunctionMaxQuery clone = null;
for (int i = 0 ; i < disjuncts.size(); i++) {
Query clause = (Query) disjuncts.get(i);
Query rewrite = clause.rewrite(reader);
if (rewrite != clause) {
if (clone == null) clone = (DisjunctionMaxQuery)this.clone();
clone.disjuncts.set(i, rewrite);
}
}
if (clone != null) return clone;
else return this;
}
代码示例来源: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;
}
内容来源于网络,如有侵权,请联系作者删除!