@@ -41,8 +41,7 @@ func NewAddressHistoryRepository(elastic *elastic_cache.Index) AddressHistoryRep
4141}
4242
4343func (r * addressHistoryRepository ) GetLatestByHash (n network.Network , hash string ) (* explorer.AddressHistory , error ) {
44- query := elastic .NewBoolQuery ()
45- query = query .Must (elastic .NewTermQuery ("hash.keyword" , hash ))
44+ query := elastic .NewBoolQuery ().Filter (elastic .NewMatchPhraseQuery ("hash" , hash ))
4645
4746 results , err := r .elastic .Client .Search (elastic_cache .AddressHistoryIndex .Get (n )).
4847 Query (query ).
@@ -54,8 +53,7 @@ func (r *addressHistoryRepository) GetLatestByHash(n network.Network, hash strin
5453}
5554
5655func (r * addressHistoryRepository ) GetFirstByHash (n network.Network , hash string ) (* explorer.AddressHistory , error ) {
57- query := elastic .NewBoolQuery ()
58- query = query .Must (elastic .NewTermQuery ("hash.keyword" , hash ))
56+ query := elastic .NewBoolQuery ().Filter (elastic .NewMatchPhraseQuery ("hash" , hash ))
5957
6058 results , err := r .elastic .Client .Search (elastic_cache .AddressHistoryIndex .Get (n )).
6159 Query (query ).
@@ -67,8 +65,7 @@ func (r *addressHistoryRepository) GetFirstByHash(n network.Network, hash string
6765}
6866
6967func (r * addressHistoryRepository ) GetCountByHash (n network.Network , hash string ) (int64 , error ) {
70- query := elastic .NewBoolQuery ()
71- query = query .Must (elastic .NewTermQuery ("hash.keyword" , hash ))
68+ query := elastic .NewBoolQuery ().Filter (elastic .NewMatchPhraseQuery ("hash" , hash ))
7269
7370 results , err := r .elastic .Client .Search (elastic_cache .AddressHistoryIndex .Get (n )).
7471 Query (query ).
@@ -84,8 +81,7 @@ func (r *addressHistoryRepository) GetCountByHash(n network.Network, hash string
8481}
8582
8683func (r * addressHistoryRepository ) GetStakingSummary (n network.Network , hash string ) (count , stakable , spendable , votingWeight int64 , err error ) {
87- query := elastic .NewBoolQuery ()
88- query = query .Must (elastic .NewTermQuery ("hash.keyword" , hash ))
84+ query := elastic .NewBoolQuery ().Filter (elastic .NewMatchPhraseQuery ("hash" , hash ))
8985
9086 changeAgg := elastic .NewNestedAggregation ().Path ("changes" )
9187 changeAgg .SubAggregation ("stakable" , elastic .NewSumAggregation ().Field ("changes.stakable" ))
@@ -123,9 +119,9 @@ func (r *addressHistoryRepository) GetStakingSummary(n network.Network, hash str
123119}
124120
125121func (r * addressHistoryRepository ) GetSpendSummary (n network.Network , hash string ) (spendableReceive , spendableSent , stakableReceive , stakableSent , votingWeightReceive , votingWeightSent int64 , err error ) {
126- query := elastic .NewBoolQuery ()
127- query = query . Must (elastic .NewTermQuery ("hash.keyword " , hash ))
128- query = query . Must (elastic .NewTermQuery ("is_stake" , false ))
122+ query := elastic .NewBoolQuery ().
123+ Filter (elastic .NewMatchPhraseQuery ("hash" , hash )).
124+ Must (elastic .NewTermQuery ("is_stake" , false ))
129125
130126 spendableReceiveAgg := elastic .NewRangeAggregation ().Field ("changes.spendable" ).Gt (0 )
131127 spendableReceiveAgg .SubAggregation ("sum" , elastic .NewSumAggregation ().Field ("changes.spendable" ))
@@ -205,8 +201,7 @@ func (r *addressHistoryRepository) GetSpendSummary(n network.Network, hash strin
205201}
206202
207203func (r * addressHistoryRepository ) GetHistoryByHash (n network.Network , hash string , p framework.Pagination , s framework.Sort , f framework.Filters ) ([]* explorer.AddressHistory , int64 , error ) {
208- query := elastic .NewBoolQuery ()
209- query = query .Must (elastic .NewTermQuery ("hash.keyword" , hash ))
204+ query := elastic .NewBoolQuery ().Filter (elastic .NewMatchPhraseQuery ("hash" , hash ))
210205
211206 options := f .OnlySupportedOptions ([]string {"type" })
212207 if option , err := options .Get ("type" ); err == nil {
@@ -305,9 +300,9 @@ func (r *addressHistoryRepository) GetStakingChart(n network.Network, period str
305300 count := 12
306301 now := time .Now ().UTC ().Truncate (time .Second )
307302
308- query := elastic .NewBoolQuery ()
309- query = query . Must (elastic .NewTermQuery ("hash.keyword " , hash ))
310- query = query . Must (elastic .NewMatchQuery ("is_stake" , true ))
303+ query := elastic .NewBoolQuery ().
304+ Filter (elastic .NewMatchPhraseQuery ("hash" , hash )).
305+ Must (elastic .NewMatchQuery ("is_stake" , true ))
311306
312307 agg := elastic .NewFilterAggregation ().Filter (query )
313308
0 commit comments