Skip to content

Commit 851b759

Browse files
committed
Fixing weight and declaring it a s final
Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
1 parent e4e0b3c commit 851b759

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

server/src/main/java/org/opensearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.apache.lucene.index.SortedSetDocValues;
4141
import org.apache.lucene.index.Terms;
4242
import org.apache.lucene.index.TermsEnum;
43+
import org.apache.lucene.search.ScoreMode;
4344
import org.apache.lucene.search.Weight;
4445
import org.apache.lucene.util.ArrayUtil;
4546
import org.apache.lucene.util.BytesRef;
@@ -98,7 +99,7 @@ public class GlobalOrdinalsStringTermsAggregator extends AbstractStringTermsAggr
9899

99100
private final String fieldName;
100101

101-
private Weight weight;
102+
private final Weight weight;
102103
private final GlobalOrdLookupFunction lookupGlobalOrd;
103104
protected final CollectionStrategy collectionStrategy;
104105
protected int segmentsWithSingleValuedOrds = 0;
@@ -151,16 +152,13 @@ public GlobalOrdinalsStringTermsAggregator(
151152
});
152153
}
153154
this.fieldName = ((ValuesSource.Bytes.WithOrdinals.FieldData) valuesSource).getIndexFieldName();
155+
this.weight = context.searcher().createWeight(context.query(), ScoreMode.COMPLETE_NO_SCORES, 1f);
154156
}
155157

156158
String descriptCollectionStrategy() {
157159
return collectionStrategy.describe();
158160
}
159161

160-
public void setWeight(Weight weight) {
161-
this.weight = weight;
162-
}
163-
164162
/**
165163
Collects term frequencies for a given field from a LeafReaderContext.
166164
@param ctx The LeafReaderContext to collect terms from

0 commit comments

Comments
 (0)