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

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

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

BooleanQuery.clone介绍

暂无

代码示例

代码示例来源:origin: lucene/lucene

public Query rewrite(IndexReader reader) throws IOException {
 if (clauses.size() == 1) {                    // optimize 1-clause queries
  BooleanClause c = (BooleanClause)clauses.elementAt(0);
  if (!c.prohibited) {			  // just return clause
   Query query = c.query.rewrite(reader);    // rewrite first
   if (getBoost() != 1.0f) {                 // incorporate boost
    if (query == c.query)                   // if rewrite was no-op
     query = (Query)query.clone();         // then clone before boost
    query.setBoost(getBoost() * query.getBoost());
   }
   return query;
  }
 }
 BooleanQuery clone = null;                    // recursively rewrite
 for (int i = 0 ; i < clauses.size(); i++) {
  BooleanClause c = (BooleanClause)clauses.elementAt(i);
  Query query = c.query.rewrite(reader);
  if (query != c.query) {                     // clause rewrote: must clone
   if (clone == null)
    clone = (BooleanQuery)this.clone();
   clone.clauses.setElementAt
    (new BooleanClause(query, c.required, c.prohibited), i);
  }
 }
 if (clone != null) {
  return clone;                               // some clauses rewrote
 } else
  return this;                                // no clauses rewrote
}

代码示例来源:origin: org.apache.lucene/lucene-core-jfrog

public Query rewrite(IndexReader reader) throws IOException {
 if (minNrShouldMatch == 0 && clauses.size() == 1) {                    // optimize 1-clause queries
  BooleanClause c = (BooleanClause)clauses.get(0);
  if (!c.isProhibited()) {			  // just return clause
   Query query = c.getQuery().rewrite(reader);    // rewrite first
   if (getBoost() != 1.0f) {                 // incorporate boost
    if (query == c.getQuery())                   // if rewrite was no-op
     query = (Query)query.clone();         // then clone before boost
    query.setBoost(getBoost() * query.getBoost());
   }
   return query;
  }
 }
 BooleanQuery clone = null;                    // recursively rewrite
 for (int i = 0 ; i < clauses.size(); i++) {
  BooleanClause c = (BooleanClause)clauses.get(i);
  Query query = c.getQuery().rewrite(reader);
  if (query != c.getQuery()) {                     // clause rewrote: must clone
   if (clone == null)
    clone = (BooleanQuery)this.clone();
   clone.clauses.set(i, new BooleanClause(query, c.getOccur()));
  }
 }
 if (clone != null) {
  return clone;                               // some clauses rewrote
 } else
  return this;                                // no clauses rewrote
}

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

public Query rewrite(IndexReader reader) throws IOException {
 if (minNrShouldMatch == 0 && clauses.size() == 1) {                    // optimize 1-clause queries
  BooleanClause c = (BooleanClause)clauses.get(0);
  if (!c.isProhibited()) {			  // just return clause
   Query query = c.getQuery().rewrite(reader);    // rewrite first
   if (getBoost() != 1.0f) {                 // incorporate boost
    if (query == c.getQuery())                   // if rewrite was no-op
     query = (Query)query.clone();         // then clone before boost
    query.setBoost(getBoost() * query.getBoost());
   }
   return query;
  }
 }
 BooleanQuery clone = null;                    // recursively rewrite
 for (int i = 0 ; i < clauses.size(); i++) {
  BooleanClause c = (BooleanClause)clauses.get(i);
  Query query = c.getQuery().rewrite(reader);
  if (query != c.getQuery()) {                     // clause rewrote: must clone
   if (clone == null)
    clone = (BooleanQuery)this.clone();
   clone.clauses.set(i, new BooleanClause(query, c.getOccur()));
  }
 }
 if (clone != null) {
  return clone;                               // some clauses rewrote
 } else
  return this;                                // no clauses rewrote
}

相关文章