diff --git a/solr/core/src/java/org/apache/solr/search/facet/FacetField.java b/solr/core/src/java/org/apache/solr/search/facet/FacetField.java index 86ce0337f86..d054f27ec1e 100644 --- a/solr/core/src/java/org/apache/solr/search/facet/FacetField.java +++ b/solr/core/src/java/org/apache/solr/search/facet/FacetField.java @@ -1158,15 +1158,14 @@ class FacetFieldProcessorStream extends FacetFieldProcessor implements Closeable // OK, we have a good bucket to return... first get bucket value before moving to next term Object bucketVal = sf.getType().toObject(sf, term); - BytesRef termCopy = BytesRef.deepCopyOf(term); + TermQuery bucketQuery = hasSubFacets ? new TermQuery(new Term(freq.field, term)) : null; term = termsEnum.next(); SimpleOrderedMap bucket = new SimpleOrderedMap<>(); bucket.add("val", bucketVal); addStats(bucket, 0); if (hasSubFacets) { - TermQuery filter = new TermQuery(new Term(freq.field, termCopy)); - processSubs(bucket, filter, termSet); + processSubs(bucket, bucketQuery, termSet); } // TODO... termSet needs to stick around for streaming sub-facets? diff --git a/solr/core/src/java/org/apache/solr/search/facet/UnInvertedField.java b/solr/core/src/java/org/apache/solr/search/facet/UnInvertedField.java index 300b6d8a6dc..152440a375b 100644 --- a/solr/core/src/java/org/apache/solr/search/facet/UnInvertedField.java +++ b/solr/core/src/java/org/apache/solr/search/facet/UnInvertedField.java @@ -122,10 +122,11 @@ public class UnInvertedField extends DocTermOrds { final BytesRef term = te.term(); if (te.docFreq() > maxTermDocFreq) { + Term t = new Term(field, term); // this makes a deep copy of the term bytes TopTerm topTerm = new TopTerm(); - topTerm.term = BytesRef.deepCopyOf(term); + topTerm.term = t.bytes(); topTerm.termNum = termNum; - topTerm.termQuery = new TermQuery(new Term(field, topTerm.term)); + topTerm.termQuery = new TermQuery(t); bigTerms.put(topTerm.termNum, topTerm);