Skip to content

Commit

Permalink
fix the filter of system_flag
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-lolong committed Nov 26, 2024
1 parent 3a903b3 commit 224efcd
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/main/java/org/vufind/solr/indexing/SolrFieldIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;

import org.apache.lucene.index.CompositeReader;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.BytesRef;
Expand Down Expand Up @@ -77,7 +79,21 @@ public void close() throws IOException
private boolean termExists(String t)
{
try {
return (this.searcher.search(new ConstantScoreQuery(new TermQuery(new Term(this.field, t))),
Query q;
if (this.filter != null) {
TermQuery tq = new TermQuery (new Term (this.field, t));
TermQuery fq = new TermQuery (new Term (this.filter, "T"));
BooleanQuery.Builder qb = new BooleanQuery.Builder();
qb.add(tq, BooleanClause.Occur.MUST);
qb.add(fq, BooleanClause.Occur.MUST);
q = qb.build();
} else {
q = new TermQuery (new Term (this.field, t));
}

// return (this.searcher.search(new ConstantScoreQuery(new TermQuery(new Term(this.field, t))),
// 1).totalHits.value > 0);
return (this.searcher.search(new ConstantScoreQuery(q),
1).totalHits.value > 0);
} catch (IOException e) {
return false;
Expand Down

0 comments on commit 224efcd

Please sign in to comment.