@@ -104,16 +104,35 @@ export const getRequestResourceListFromFilter = async (
104104 esType ,
105105 filter ,
106106 filterSelf ,
107- ) => textAggregation (
108- { esInstance, esIndex, esType } ,
109- { field : config . esConfig . authFilterField , filter, filterSelf } ,
110- ) . then ( ( res ) => ( res . map ( ( item ) => item . key ) ) ) ;
107+ ) => {
108+ const authField = config . esConfig . authFilterField ;
109+ const dotIdx = authField . lastIndexOf ( '.' ) ;
110+ const field = dotIdx >= 0 ? authField . slice ( dotIdx + 1 ) : authField ;
111+ const nestedPath = dotIdx >= 0 ? authField . slice ( 0 , dotIdx ) : undefined ;
112+
113+ return textAggregation (
114+ { esInstance, esIndex, esType } ,
115+ { field, filter, filterSelf, nestedPath } ,
116+ ) . then ( ( res ) => res . map ( ( item ) => item . key ) ) ;
117+ } ;
111118
112119export const buildFilterWithResourceList = ( resourceList = [ ] ) => {
113- const filter = {
120+ const authField = config . esConfig . authFilterField ;
121+ const dotIdx = authField . lastIndexOf ( '.' ) ;
122+ if ( dotIdx >= 0 ) {
123+ const nestedPath = authField . slice ( 0 , dotIdx ) ;
124+ return {
125+ nested : {
126+ path : nestedPath ,
127+ IN : {
128+ [ authField ] : [ ...resourceList ] ,
129+ } ,
130+ } ,
131+ } ;
132+ }
133+ return {
114134 IN : {
115- [ config . esConfig . authFilterField ] : [ ...resourceList ] ,
135+ [ authField ] : [ ...resourceList ] ,
116136 } ,
117137 } ;
118- return filter ;
119138} ;
0 commit comments