diff --git a/config/attributescfg.go b/config/attributescfg.go index e06339a5f..cb9af3cb5 100644 --- a/config/attributescfg.go +++ b/config/attributescfg.go @@ -26,6 +26,7 @@ type AttributeSCfg struct { IndexedSelects bool StringIndexedFields *[]string PrefixIndexedFields *[]string + SuffixIndexedFields *[]string ProcessRuns int NestedFields bool } @@ -54,6 +55,13 @@ func (alS *AttributeSCfg) loadFromJsonCfg(jsnCfg *AttributeSJsonCfg) (err error) } alS.PrefixIndexedFields = &pif } + if jsnCfg.Suffix_indexed_fields != nil { + sif := make([]string, len(*jsnCfg.Suffix_indexed_fields)) + for i, fID := range *jsnCfg.Suffix_indexed_fields { + sif[i] = fID + } + alS.SuffixIndexedFields = &sif + } if jsnCfg.Process_runs != nil { alS.ProcessRuns = *jsnCfg.Process_runs } diff --git a/config/chargerscfg.go b/config/chargerscfg.go index fe55749cd..27d8c8461 100644 --- a/config/chargerscfg.go +++ b/config/chargerscfg.go @@ -31,6 +31,7 @@ type ChargerSCfg struct { AttributeSConns []string StringIndexedFields *[]string PrefixIndexedFields *[]string + SuffixIndexedFields *[]string NestedFields bool } @@ -69,6 +70,13 @@ func (cS *ChargerSCfg) loadFromJsonCfg(jsnCfg *ChargerSJsonCfg) (err error) { } cS.PrefixIndexedFields = &pif } + if jsnCfg.Suffix_indexed_fields != nil { + sif := make([]string, len(*jsnCfg.Suffix_indexed_fields)) + for i, fID := range *jsnCfg.Suffix_indexed_fields { + sif[i] = fID + } + cS.SuffixIndexedFields = &sif + } if jsnCfg.Nested_fields != nil { cS.NestedFields = *jsnCfg.Nested_fields } diff --git a/config/config_defaults.go b/config/config_defaults.go index a894a5193..84a529d16 100755 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -580,6 +580,7 @@ const CGRATES_CFG_JSON = ` "indexed_selects": true, // enable profile matching exclusively on indexes //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing + "suffix_indexed_fields": [], // query indexes based on these fields for faster processing "nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level) "process_runs": 1, // number of run loops when processing event }, @@ -591,6 +592,7 @@ const CGRATES_CFG_JSON = ` "indexed_selects": true, // enable profile matching exclusively on indexes //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing + "suffix_indexed_fields": [], // query indexes based on these fields for faster processing "nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level) }, @@ -602,6 +604,7 @@ const CGRATES_CFG_JSON = ` "indexed_selects": true, // enable profile matching exclusively on indexes //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing + "suffix_indexed_fields": [], // query indexes based on these fields for faster processing "nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level) }, @@ -614,6 +617,7 @@ const CGRATES_CFG_JSON = ` "indexed_selects": true, // enable profile matching exclusively on indexes //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing + "suffix_indexed_fields": [], // query indexes based on these fields for faster processing "nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level) }, @@ -624,6 +628,7 @@ const CGRATES_CFG_JSON = ` "indexed_selects": true, // enable profile matching exclusively on indexes //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing + "suffix_indexed_fields": [], // query indexes based on these fields for faster processing "nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level) }, @@ -633,6 +638,7 @@ const CGRATES_CFG_JSON = ` "indexed_selects": true, // enable profile matching exclusively on indexes //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing + "suffix_indexed_fields": [], // query indexes based on these fields for faster processing "nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level) "attributes_conns": [], // connections to AttributeS for altering events before route queries: <""|*internal|$rpc_conns_id> "resources_conns": [], // connections to ResourceS for *res sorting, empty to disable functionality: <""|*internal|$rpc_conns_id> @@ -907,6 +913,7 @@ const CGRATES_CFG_JSON = ` "indexed_selects": true, // enable profile matching exclusively on indexes //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing + "suffix_indexed_fields": [], // query indexes based on these fields for faster processing "nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level) "attributes_conns": [], // connections to AttributeS for API authorization, empty to disable auth functionality: <""|*internal|$rpc_conns_id> }, @@ -930,10 +937,12 @@ const CGRATES_CFG_JSON = ` "indexed_selects": true, // enable profile matching exclusively on indexes //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing + "suffix_indexed_fields": [], // query indexes based on these fields for faster processing "nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level) "rate_indexed_selects": true, // enable profile matching exclusively on indexes //"rate_string_indexed_fields": [], // query indexes based on these fields for faster processing "rate_prefix_indexed_fields": [], // query indexes based on these fields for faster processing + "rate_suffix_indexed_fields": [], // query indexes based on these fields for faster processing "rate_nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level) }, diff --git a/config/config_json_test.go b/config/config_json_test.go index 20a5009e0..b1440ae40 100755 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -958,6 +958,7 @@ func TestDfAttributeServJsonCfg(t *testing.T) { Indexed_selects: utils.BoolPointer(true), String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, + Suffix_indexed_fields: &[]string{}, Process_runs: utils.IntPointer(1), Nested_fields: utils.BoolPointer(false), } @@ -975,6 +976,7 @@ func TestDfChargerServJsonCfg(t *testing.T) { Attributes_conns: &[]string{}, String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, + Suffix_indexed_fields: &[]string{}, Nested_fields: utils.BoolPointer(false), } if cfg, err := dfCgrJSONCfg.ChargerServJsonCfg(); err != nil { @@ -1005,6 +1007,7 @@ func TestDfResourceLimiterSJsonCfg(t *testing.T) { Store_interval: utils.StringPointer(""), String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, + Suffix_indexed_fields: &[]string{}, Nested_fields: utils.BoolPointer(false), } if cfg, err := dfCgrJSONCfg.ResourceSJsonCfg(); err != nil { @@ -1023,6 +1026,7 @@ func TestDfStatServiceJsonCfg(t *testing.T) { Thresholds_conns: &[]string{}, String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, + Suffix_indexed_fields: &[]string{}, Nested_fields: utils.BoolPointer(false), } if cfg, err := dfCgrJSONCfg.StatSJsonCfg(); err != nil { @@ -1039,6 +1043,7 @@ func TestDfThresholdSJsonCfg(t *testing.T) { Store_interval: utils.StringPointer(""), String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, + Suffix_indexed_fields: &[]string{}, Nested_fields: utils.BoolPointer(false), } if cfg, err := dfCgrJSONCfg.ThresholdSJsonCfg(); err != nil { @@ -1054,6 +1059,7 @@ func TestDfRouteSJsonCfg(t *testing.T) { Indexed_selects: utils.BoolPointer(true), String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, + Suffix_indexed_fields: &[]string{}, Attributes_conns: &[]string{}, Resources_conns: &[]string{}, Stats_conns: &[]string{}, @@ -1698,6 +1704,7 @@ func TestDfDispatcherSJsonCfg(t *testing.T) { Indexed_selects: utils.BoolPointer(true), String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, + Suffix_indexed_fields: &[]string{}, Attributes_conns: &[]string{}, Nested_fields: utils.BoolPointer(false), } @@ -1980,10 +1987,12 @@ func TestDfRateSJsonCfg(t *testing.T) { Indexed_selects: utils.BoolPointer(true), String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, + Suffix_indexed_fields: &[]string{}, Nested_fields: utils.BoolPointer(false), Rate_indexed_selects: utils.BoolPointer(true), Rate_string_indexed_fields: nil, Rate_prefix_indexed_fields: &[]string{}, + Rate_suffix_indexed_fields: &[]string{}, Rate_nested_fields: utils.BoolPointer(false), } if cfg, err := dfCgrJSONCfg.RateCfgJson(); err != nil { diff --git a/config/config_test.go b/config/config_test.go index 1bc86967d..af08d9980 100755 --- a/config/config_test.go +++ b/config/config_test.go @@ -727,6 +727,7 @@ func TestCgrCfgJSONDefaultSChargerSCfg(t *testing.T) { AttributeSConns: []string{}, StringIndexedFields: nil, PrefixIndexedFields: &[]string{}, + SuffixIndexedFields: &[]string{}, } if !reflect.DeepEqual(eChargerSCfg, cgrCfg.chargerSCfg) { t.Errorf("received: %+v, expecting: %+v", eChargerSCfg, cgrCfg.chargerSCfg) @@ -741,6 +742,7 @@ func TestCgrCfgJSONDefaultsResLimCfg(t *testing.T) { StoreInterval: 0, StringIndexedFields: nil, PrefixIndexedFields: &[]string{}, + SuffixIndexedFields: &[]string{}, } if !reflect.DeepEqual(cgrCfg.resourceSCfg, eResLiCfg) { t.Errorf("expecting: %s, received: %s", utils.ToJSON(eResLiCfg), utils.ToJSON(cgrCfg.resourceSCfg)) @@ -756,6 +758,7 @@ func TestCgrCfgJSONDefaultStatsCfg(t *testing.T) { ThresholdSConns: []string{}, StringIndexedFields: nil, PrefixIndexedFields: &[]string{}, + SuffixIndexedFields: &[]string{}, } if !reflect.DeepEqual(cgrCfg.statsCfg, eStatsCfg) { t.Errorf("received: %+v, expecting: %+v", cgrCfg.statsCfg, eStatsCfg) @@ -769,6 +772,7 @@ func TestCgrCfgJSONDefaultThresholdSCfg(t *testing.T) { StoreInterval: 0, StringIndexedFields: nil, PrefixIndexedFields: &[]string{}, + SuffixIndexedFields: &[]string{}, } if !reflect.DeepEqual(eThresholdSCfg, cgrCfg.thresholdSCfg) { t.Errorf("received: %+v, expecting: %+v", eThresholdSCfg, cgrCfg.thresholdSCfg) @@ -781,6 +785,7 @@ func TestCgrCfgJSONDefaultRouteSCfg(t *testing.T) { IndexedSelects: true, StringIndexedFields: nil, PrefixIndexedFields: &[]string{}, + SuffixIndexedFields: &[]string{}, AttributeSConns: []string{}, ResourceSConns: []string{}, StatSConns: []string{}, @@ -1685,6 +1690,7 @@ func TestCgrCfgJSONDefaultDispatcherSCfg(t *testing.T) { IndexedSelects: true, StringIndexedFields: nil, PrefixIndexedFields: &[]string{}, + SuffixIndexedFields: &[]string{}, AttributeSConns: []string{}, } if !reflect.DeepEqual(cgrCfg.dispatcherSCfg, eDspSCfg) { @@ -1838,10 +1844,12 @@ func TestCgrCfgJSONDefaultRateCfg(t *testing.T) { IndexedSelects: true, StringIndexedFields: nil, PrefixIndexedFields: &[]string{}, + SuffixIndexedFields: &[]string{}, NestedFields: false, RateIndexedSelects: true, RateStringIndexedFields: nil, RatePrefixIndexedFields: &[]string{}, + RateSuffixIndexedFields: &[]string{}, RateNestedFields: false, } if !reflect.DeepEqual(cgrCfg.rateSCfg, eCfg) { diff --git a/config/dispatchercfg.go b/config/dispatchercfg.go index 30122123f..629fba241 100755 --- a/config/dispatchercfg.go +++ b/config/dispatchercfg.go @@ -30,6 +30,7 @@ type DispatcherSCfg struct { IndexedSelects bool StringIndexedFields *[]string PrefixIndexedFields *[]string + SuffixIndexedFields *[]string AttributeSConns []string NestedFields bool } @@ -58,6 +59,13 @@ func (dps *DispatcherSCfg) loadFromJsonCfg(jsnCfg *DispatcherSJsonCfg) (err erro } dps.PrefixIndexedFields = &pif } + if jsnCfg.Suffix_indexed_fields != nil { + sif := make([]string, len(*jsnCfg.Suffix_indexed_fields)) + for i, fID := range *jsnCfg.Suffix_indexed_fields { + sif[i] = fID + } + dps.SuffixIndexedFields = &sif + } if jsnCfg.Attributes_conns != nil { dps.AttributeSConns = make([]string, len(*jsnCfg.Attributes_conns)) for idx, connID := range *jsnCfg.Attributes_conns { diff --git a/config/libconfig_json.go b/config/libconfig_json.go index bae902559..598b08724 100755 --- a/config/libconfig_json.go +++ b/config/libconfig_json.go @@ -408,6 +408,7 @@ type AttributeSJsonCfg struct { Indexed_selects *bool String_indexed_fields *[]string Prefix_indexed_fields *[]string + Suffix_indexed_fields *[]string Nested_fields *bool // applies when indexed fields is not defined Process_runs *int } @@ -419,6 +420,7 @@ type ChargerSJsonCfg struct { Attributes_conns *[]string String_indexed_fields *[]string Prefix_indexed_fields *[]string + Suffix_indexed_fields *[]string Nested_fields *bool // applies when indexed fields is not defined } @@ -430,6 +432,7 @@ type ResourceSJsonCfg struct { Store_interval *string String_indexed_fields *[]string Prefix_indexed_fields *[]string + Suffix_indexed_fields *[]string Nested_fields *bool // applies when indexed fields is not defined } @@ -442,6 +445,7 @@ type StatServJsonCfg struct { Thresholds_conns *[]string String_indexed_fields *[]string Prefix_indexed_fields *[]string + Suffix_indexed_fields *[]string Nested_fields *bool // applies when indexed fields is not defined } @@ -452,15 +456,17 @@ type ThresholdSJsonCfg struct { Store_interval *string String_indexed_fields *[]string Prefix_indexed_fields *[]string + Suffix_indexed_fields *[]string Nested_fields *bool // applies when indexed fields is not defined } -// Rounte service config section +// Route service config section type RouteSJsonCfg struct { Enabled *bool Indexed_selects *bool String_indexed_fields *[]string Prefix_indexed_fields *[]string + Suffix_indexed_fields *[]string Nested_fields *bool // applies when indexed fields is not defined Attributes_conns *[]string Resources_conns *[]string @@ -533,6 +539,7 @@ type DispatcherSJsonCfg struct { Indexed_selects *bool String_indexed_fields *[]string Prefix_indexed_fields *[]string + Suffix_indexed_fields *[]string Nested_fields *bool // applies when indexed fields is not defined Attributes_conns *[]string } @@ -613,10 +620,12 @@ type RateSJsonCfg struct { Indexed_selects *bool String_indexed_fields *[]string Prefix_indexed_fields *[]string + Suffix_indexed_fields *[]string Nested_fields *bool // applies when indexed fields is not defined Rate_indexed_selects *bool Rate_string_indexed_fields *[]string Rate_prefix_indexed_fields *[]string + Rate_suffix_indexed_fields *[]string Rate_nested_fields *bool // applies when indexed fields is not defined } diff --git a/config/ratescfg.go b/config/ratescfg.go index bfe0433fa..1c95247cb 100644 --- a/config/ratescfg.go +++ b/config/ratescfg.go @@ -27,10 +27,12 @@ type RateSCfg struct { IndexedSelects bool StringIndexedFields *[]string PrefixIndexedFields *[]string + SuffixIndexedFields *[]string NestedFields bool RateIndexedSelects bool RateStringIndexedFields *[]string RatePrefixIndexedFields *[]string + RateSuffixIndexedFields *[]string RateNestedFields bool } @@ -58,6 +60,13 @@ func (rCfg *RateSCfg) loadFromJsonCfg(jsnCfg *RateSJsonCfg) (err error) { } rCfg.PrefixIndexedFields = &pif } + if jsnCfg.Suffix_indexed_fields != nil { + sif := make([]string, len(*jsnCfg.Suffix_indexed_fields)) + for i, fID := range *jsnCfg.Suffix_indexed_fields { + sif[i] = fID + } + rCfg.SuffixIndexedFields = &sif + } if jsnCfg.Nested_fields != nil { rCfg.NestedFields = *jsnCfg.Nested_fields } @@ -79,6 +88,13 @@ func (rCfg *RateSCfg) loadFromJsonCfg(jsnCfg *RateSJsonCfg) (err error) { } rCfg.RatePrefixIndexedFields = &pif } + if jsnCfg.Rate_suffix_indexed_fields != nil { + sif := make([]string, len(*jsnCfg.Rate_suffix_indexed_fields)) + for i, fID := range *jsnCfg.Rate_suffix_indexed_fields { + sif[i] = fID + } + rCfg.RateSuffixIndexedFields = &sif + } if jsnCfg.Rate_nested_fields != nil { rCfg.RateNestedFields = *jsnCfg.Rate_nested_fields } diff --git a/config/resourcescfg.go b/config/resourcescfg.go index 070a94880..2dfb6abc2 100644 --- a/config/resourcescfg.go +++ b/config/resourcescfg.go @@ -32,6 +32,7 @@ type ResourceSConfig struct { StoreInterval time.Duration // Dump regularly from cache into dataDB StringIndexedFields *[]string PrefixIndexedFields *[]string + SuffixIndexedFields *[]string NestedFields bool } @@ -75,6 +76,13 @@ func (rlcfg *ResourceSConfig) loadFromJsonCfg(jsnCfg *ResourceSJsonCfg) (err err } rlcfg.PrefixIndexedFields = &pif } + if jsnCfg.Suffix_indexed_fields != nil { + sif := make([]string, len(*jsnCfg.Suffix_indexed_fields)) + for i, fID := range *jsnCfg.Suffix_indexed_fields { + sif[i] = fID + } + rlcfg.SuffixIndexedFields = &sif + } if jsnCfg.Nested_fields != nil { rlcfg.NestedFields = *jsnCfg.Nested_fields } diff --git a/config/routescfg.go b/config/routescfg.go index b3c80e12d..bcfc351aa 100644 --- a/config/routescfg.go +++ b/config/routescfg.go @@ -30,6 +30,7 @@ type RouteSCfg struct { IndexedSelects bool StringIndexedFields *[]string PrefixIndexedFields *[]string + SuffixIndexedFields *[]string AttributeSConns []string ResourceSConns []string StatSConns []string @@ -62,6 +63,13 @@ func (rts *RouteSCfg) loadFromJsonCfg(jsnCfg *RouteSJsonCfg) (err error) { } rts.PrefixIndexedFields = &pif } + if jsnCfg.Suffix_indexed_fields != nil { + sif := make([]string, len(*jsnCfg.Suffix_indexed_fields)) + for i, fID := range *jsnCfg.Suffix_indexed_fields { + sif[i] = fID + } + rts.SuffixIndexedFields = &sif + } if jsnCfg.Attributes_conns != nil { rts.AttributeSConns = make([]string, len(*jsnCfg.Attributes_conns)) for idx, conn := range *jsnCfg.Attributes_conns { diff --git a/config/statscfg.go b/config/statscfg.go index 1cbe06513..9535e2837 100644 --- a/config/statscfg.go +++ b/config/statscfg.go @@ -33,6 +33,7 @@ type StatSCfg struct { ThresholdSConns []string StringIndexedFields *[]string PrefixIndexedFields *[]string + SuffixIndexedFields *[]string NestedFields bool } @@ -79,6 +80,13 @@ func (st *StatSCfg) loadFromJsonCfg(jsnCfg *StatServJsonCfg) (err error) { } st.PrefixIndexedFields = &pif } + if jsnCfg.Suffix_indexed_fields != nil { + sif := make([]string, len(*jsnCfg.Suffix_indexed_fields)) + for i, fID := range *jsnCfg.Suffix_indexed_fields { + sif[i] = fID + } + st.SuffixIndexedFields = &sif + } if jsnCfg.Nested_fields != nil { st.NestedFields = *jsnCfg.Nested_fields } diff --git a/config/thresholdscfg.go b/config/thresholdscfg.go index 39fb52c54..4cae80392 100644 --- a/config/thresholdscfg.go +++ b/config/thresholdscfg.go @@ -30,6 +30,7 @@ type ThresholdSCfg struct { StoreInterval time.Duration // Dump regularly from cache into dataDB StringIndexedFields *[]string PrefixIndexedFields *[]string + SuffixIndexedFields *[]string NestedFields bool } @@ -62,6 +63,13 @@ func (t *ThresholdSCfg) loadFromJsonCfg(jsnCfg *ThresholdSJsonCfg) (err error) { } t.PrefixIndexedFields = &pif } + if jsnCfg.Suffix_indexed_fields != nil { + sif := make([]string, len(*jsnCfg.Suffix_indexed_fields)) + for i, fID := range *jsnCfg.Suffix_indexed_fields { + sif[i] = fID + } + t.SuffixIndexedFields = &sif + } if jsnCfg.Nested_fields != nil { t.NestedFields = *jsnCfg.Nested_fields } diff --git a/dispatchers/dispatchers.go b/dispatchers/dispatchers.go index a8476d619..0a28c40d8 100755 --- a/dispatchers/dispatchers.go +++ b/dispatchers/dispatchers.go @@ -120,6 +120,7 @@ func (dS *DispatcherService) dispatcherProfileForEvent(ev *utils.CGREvent, prflIDs, err := engine.MatchingItemIDsForEvent(evNm, dS.cfg.DispatcherSCfg().StringIndexedFields, dS.cfg.DispatcherSCfg().PrefixIndexedFields, + dS.cfg.DispatcherSCfg().SuffixIndexedFields, dS.dm, utils.CacheDispatcherFilterIndexes, idxKeyPrfx, dS.cfg.DispatcherSCfg().IndexedSelects, dS.cfg.DispatcherSCfg().NestedFields, @@ -132,6 +133,7 @@ func (dS *DispatcherService) dispatcherProfileForEvent(ev *utils.CGREvent, prflIDs, err = engine.MatchingItemIDsForEvent(evNm, dS.cfg.DispatcherSCfg().StringIndexedFields, dS.cfg.DispatcherSCfg().PrefixIndexedFields, + dS.cfg.DispatcherSCfg().SuffixIndexedFields, dS.dm, utils.CacheDispatcherFilterIndexes, anyIdxPrfx, dS.cfg.DispatcherSCfg().IndexedSelects, dS.cfg.DispatcherSCfg().NestedFields, diff --git a/engine/attributes.go b/engine/attributes.go index 6cb692d52..b2875c7f9 100644 --- a/engine/attributes.go +++ b/engine/attributes.go @@ -75,6 +75,7 @@ func (alS *AttributeService) attributeProfileForEvent(args *AttrArgsProcessEvent aPrflIDs, err := MatchingItemIDsForEvent(evNm, alS.cgrcfg.AttributeSCfg().StringIndexedFields, alS.cgrcfg.AttributeSCfg().PrefixIndexedFields, + alS.cgrcfg.AttributeSCfg().SuffixIndexedFields, alS.dm, utils.CacheAttributeFilterIndexes, attrIdxKey, alS.cgrcfg.AttributeSCfg().IndexedSelects, alS.cgrcfg.AttributeSCfg().NestedFields, @@ -86,6 +87,7 @@ func (alS *AttributeService) attributeProfileForEvent(args *AttrArgsProcessEvent if aPrflIDs, err = MatchingItemIDsForEvent(evNm, alS.cgrcfg.AttributeSCfg().StringIndexedFields, alS.cgrcfg.AttributeSCfg().PrefixIndexedFields, + alS.cgrcfg.AttributeSCfg().SuffixIndexedFields, alS.dm, utils.CacheAttributeFilterIndexes, utils.ConcatenatedKey(args.Tenant, utils.META_ANY), alS.cgrcfg.AttributeSCfg().IndexedSelects, diff --git a/engine/chargers.go b/engine/chargers.go index 9971e4e3f..4ed81a4ff 100644 --- a/engine/chargers.go +++ b/engine/chargers.go @@ -64,6 +64,7 @@ func (cS *ChargerService) matchingChargerProfilesForEvent(cgrEv *utils.CGREventW cpIDs, err := MatchingItemIDsForEvent(evNm, cS.cfg.ChargerSCfg().StringIndexedFields, cS.cfg.ChargerSCfg().PrefixIndexedFields, + cS.cfg.ChargerSCfg().SuffixIndexedFields, cS.dm, utils.CacheChargerFilterIndexes, cgrEv.Tenant, cS.cfg.ChargerSCfg().IndexedSelects, cS.cfg.ChargerSCfg().NestedFields, diff --git a/engine/filterhelpers.go b/engine/filterhelpers.go index ac99d2607..c3509f7bf 100644 --- a/engine/filterhelpers.go +++ b/engine/filterhelpers.go @@ -29,7 +29,7 @@ import ( // MatchingItemIDsForEvent returns the list of item IDs matching fieldName/fieldValue for an event // fieldIDs limits the fields which are checked against indexes // helper on top of dataDB.GetIndexes, adding utils.ANY to list of fields queried -func MatchingItemIDsForEvent(ev utils.MapStorage, stringFldIDs, prefixFldIDs *[]string, +func MatchingItemIDsForEvent(ev utils.MapStorage, stringFldIDs, prefixFldIDs, suffixFldIDs *[]string, dm *DataManager, cacheID, itemIDPrefix string, indexedSelects, nestedFields bool) (itemIDs utils.StringSet, err error) { itemIDs = make(utils.StringSet) var allFieldIDs []string diff --git a/engine/resources.go b/engine/resources.go index d686c2705..4a3ee48db 100644 --- a/engine/resources.go +++ b/engine/resources.go @@ -478,6 +478,7 @@ func (rS *ResourceService) matchingResourcesForEvent(ev *utils.CGREvent, rIDs, err = MatchingItemIDsForEvent(evNm, rS.cgrcfg.ResourceSCfg().StringIndexedFields, rS.cgrcfg.ResourceSCfg().PrefixIndexedFields, + rS.cgrcfg.ResourceSCfg().SuffixIndexedFields, rS.dm, utils.CacheResourceFilterIndexes, ev.Tenant, rS.cgrcfg.ResourceSCfg().IndexedSelects, rS.cgrcfg.ResourceSCfg().NestedFields, diff --git a/engine/routes.go b/engine/routes.go index ee8d2b285..9b68c0e62 100644 --- a/engine/routes.go +++ b/engine/routes.go @@ -158,6 +158,7 @@ func (rpS *RouteService) matchingRouteProfilesForEvent(ev *utils.CGREvent, singl rPrfIDs, err := MatchingItemIDsForEvent(evNm, rpS.cgrcfg.RouteSCfg().StringIndexedFields, rpS.cgrcfg.RouteSCfg().PrefixIndexedFields, + rpS.cgrcfg.RouteSCfg().SuffixIndexedFields, rpS.dm, utils.CacheRouteFilterIndexes, ev.Tenant, rpS.cgrcfg.RouteSCfg().IndexedSelects, rpS.cgrcfg.RouteSCfg().NestedFields, diff --git a/engine/stats.go b/engine/stats.go index bd22f68ac..551ebe5ac 100644 --- a/engine/stats.go +++ b/engine/stats.go @@ -157,6 +157,7 @@ func (sS *StatService) matchingStatQueuesForEvent(args *StatsArgsProcessEvent) ( sqIDs, err = MatchingItemIDsForEvent(evNm, sS.cgrcfg.StatSCfg().StringIndexedFields, sS.cgrcfg.StatSCfg().PrefixIndexedFields, + sS.cgrcfg.StatSCfg().SuffixIndexedFields, sS.dm, utils.CacheStatFilterIndexes, args.Tenant, sS.cgrcfg.StatSCfg().IndexedSelects, sS.cgrcfg.StatSCfg().NestedFields, diff --git a/engine/thresholds.go b/engine/thresholds.go index 31a899cbb..c6fcb55d2 100644 --- a/engine/thresholds.go +++ b/engine/thresholds.go @@ -241,6 +241,7 @@ func (tS *ThresholdService) matchingThresholdsForEvent(args *ArgsProcessEvent) ( tIDs, err = MatchingItemIDsForEvent(evNm, tS.cgrcfg.ThresholdSCfg().StringIndexedFields, tS.cgrcfg.ThresholdSCfg().PrefixIndexedFields, + tS.cgrcfg.ThresholdSCfg().SuffixIndexedFields, tS.dm, utils.CacheThresholdFilterIndexes, args.Tenant, tS.cgrcfg.ThresholdSCfg().IndexedSelects, tS.cgrcfg.ThresholdSCfg().NestedFields, diff --git a/engine/z_filterhelpers_test.go b/engine/z_filterhelpers_test.go index 0052dbcae..c70b23f3f 100644 --- a/engine/z_filterhelpers_test.go +++ b/engine/z_filterhelpers_test.go @@ -86,7 +86,7 @@ func TestFilterMatchingItemIDsForEvent(t *testing.T) { utils.AnswerTime: time.Date(2014, 7, 14, 14, 30, 0, 0, time.UTC), "Field": "profile", }} - aPrflIDs, err := MatchingItemIDsForEvent(matchEV, nil, nil, + aPrflIDs, err := MatchingItemIDsForEvent(matchEV, nil, nil, nil, dmMatch, utils.CacheAttributeFilterIndexes, tntCtx, true, false) if err != nil { t.Errorf("Error: %+v", err) @@ -98,7 +98,7 @@ func TestFilterMatchingItemIDsForEvent(t *testing.T) { matchEV = utils.MapStorage{utils.MetaReq: map[string]interface{}{ "Field": "profilePrefix", }} - aPrflIDs, err = MatchingItemIDsForEvent(matchEV, nil, nil, + aPrflIDs, err = MatchingItemIDsForEvent(matchEV, nil, nil, nil, dmMatch, utils.CacheAttributeFilterIndexes, tntCtx, true, false) if err != nil { t.Errorf("Error: %+v", err) @@ -162,7 +162,7 @@ func TestFilterMatchingItemIDsForEvent2(t *testing.T) { utils.AnswerTime: time.Date(2014, 7, 14, 14, 30, 0, 0, time.UTC), "CallCost": map[string]interface{}{"Account": 1001}, }} - aPrflIDs, err := MatchingItemIDsForEvent(matchEV, nil, nil, + aPrflIDs, err := MatchingItemIDsForEvent(matchEV, nil, nil, nil, dmMatch, utils.CacheAttributeFilterIndexes, tntCtx, true, true) if err != nil { t.Errorf("Error: %+v", err) @@ -174,7 +174,7 @@ func TestFilterMatchingItemIDsForEvent2(t *testing.T) { matchEV = utils.MapStorage{utils.MetaReq: map[string]interface{}{ "CallCost": map[string]interface{}{"Field": "profilePrefix"}, }} - aPrflIDs, err = MatchingItemIDsForEvent(matchEV, nil, nil, + aPrflIDs, err = MatchingItemIDsForEvent(matchEV, nil, nil, nil, dmMatch, utils.CacheAttributeFilterIndexes, tntCtx, true, true) if err != nil { t.Errorf("Error: %+v", err) diff --git a/rates/rates.go b/rates/rates.go index 1ab65d6d5..2727d0ec6 100644 --- a/rates/rates.go +++ b/rates/rates.go @@ -79,6 +79,7 @@ func (rS *RateS) matchingRateProfileForEvent(args *ArgsCostForEvent, rPfIDs []st evNm, rS.cfg.RateSCfg().StringIndexedFields, rS.cfg.RateSCfg().PrefixIndexedFields, + rS.cfg.RateSCfg().SuffixIndexedFields, rS.dm, utils.CacheRateProfilesFilterIndexes, args.CGREvent.Tenant,