*accounts, *stats, *resources, *libphnumber are not indexing

This commit is contained in:
porosnicuadrian
2021-05-26 11:00:13 +03:00
committed by Dan Christian Bogos
parent 16b55a747f
commit c9341ff3de
3 changed files with 47 additions and 1 deletions

View File

@@ -123,7 +123,17 @@ func (apierSv1 *APIerSv1) composeArgsReload(tnt, cacheID, itemID string, filterI
continue
}
isDyn := strings.HasPrefix(flt.Element, utils.DynamicDataPrefix)
for _, notIndex := range utils.ToNotBeIndexed { // element with ~*stats, ~*resources, ~*accounts, ~*libphonenumber to not be indexed
if strings.HasPrefix(flt.Element, notIndex) {
continue
}
}
for _, fldVal := range flt.Values {
for _, notIndex := range utils.ToNotBeIndexed { // value with ~*stats, ~*resources, ~*accounts, ~*libphonenumber to not be indexed
if strings.HasPrefix(fldVal, notIndex) {
continue
}
}
if isDyn {
if !strings.HasPrefix(fldVal, utils.DynamicDataPrefix) {
indxIDs = append(indxIDs, utils.ConcatenatedKey(flt.Type, flt.Element[1:], fldVal))
@@ -273,7 +283,17 @@ func composeCacheArgsForFilter(dm *engine.DataManager, fltr *engine.Filter, tnt,
continue
}
isDyn := strings.HasPrefix(flt.Element, utils.DynamicDataPrefix)
for _, notIndex := range utils.ToNotBeIndexed { // element with ~*stats, ~*resources, ~*accounts, ~*libphonenumber to not be indexed
if strings.HasPrefix(flt.Element, notIndex) {
continue
}
}
for _, fldVal := range flt.Values {
for _, notIndex := range utils.ToNotBeIndexed { // value with ~*stats, ~*resources, ~*accounts, ~*libphonenumber to not be indexed
if strings.HasPrefix(fldVal, notIndex) {
continue
}
}
if isDyn {
if !strings.HasPrefix(fldVal, utils.DynamicDataPrefix) {
indxIDs = append(indxIDs, utils.ConcatenatedKey(flt.Type, flt.Element[1:], fldVal))

View File

@@ -75,10 +75,19 @@ func newFilterIndex(dm *DataManager, idxItmType, tnt, ctx, itemID string, filter
if !FilterIndexTypes.Has(flt.Type) {
continue
}
isDyn := strings.HasPrefix(flt.Element, utils.DynamicDataPrefix)
for _, notIndex := range utils.ToNotBeIndexed { // element with ~*stats, ~*resources, ~*accounts, ~*libphonenumber to not be indexed
if strings.HasPrefix(flt.Element, notIndex) {
continue
}
}
for _, fldVal := range flt.Values {
var idxKey string
for _, notIndex := range utils.ToNotBeIndexed { // value with ~*stats, ~*resources, ~*accounts, ~*libphonenumber to not be indexed
if strings.HasPrefix(fldVal, notIndex) {
continue
}
}
if isDyn {
if strings.HasPrefix(fldVal, utils.DynamicDataPrefix) { // do not index if both the element and the value is dynamic
continue
@@ -521,8 +530,18 @@ func UpdateFilterIndex(dm *DataManager, oldFlt, newFlt *Filter) (err error) {
continue
}
isDyn := strings.HasPrefix(flt.Element, utils.DynamicDataPrefix)
for _, notIndex := range utils.ToNotBeIndexed { // element with ~*stats, ~*resources, ~*accounts, ~*libphonenumber to not be indexed
if strings.HasPrefix(flt.Element, notIndex) {
continue
}
}
for _, fldVal := range flt.Values {
var idxKey string
for _, notIndex := range utils.ToNotBeIndexed { // value with ~*stats, ~*resources, ~*accounts, ~*libphonenumber to not be indexed
if strings.HasPrefix(flt.Element, notIndex) {
continue
}
}
if isDyn {
if strings.HasPrefix(fldVal, utils.DynamicDataPrefix) { // do not index if both the element and the value is dynamic
continue

View File

@@ -156,6 +156,13 @@ var (
TBLTPDispatchers: CacheTBLTPDispatchers,
TBLTPDispatcherHosts: CacheTBLTPDispatcherHosts,
}
// Element or values of a filter that starts with one of this should not be indexed
ToNotBeIndexed = []string{DynamicDataPrefix + MetaAccounts,
DynamicDataPrefix + MetaStats,
DynamicDataPrefix + MetaResources,
DynamicDataPrefix + MetaLibPhoneNumber}
// ProtectedSFlds are the fields that sessions should not alter
ProtectedSFlds = NewStringSet([]string{CGRID, OriginHost, OriginID, Usage})
ArgCacheToPrefix = map[string]string{