How to index department from one of the index where empId is same as loggedin user Id.
here allUsers stores Record data.
Discussion posts and replies are publicly visible
you can query the data based on loggedin user details from which you can find logged in user id and thenfind the indexes where these id exists , and extract the department from the indexestake reference from this code
index(local!allUsers[recordType!yourRecord.field.department],wherecontains(local!loggedInUserId,local!allUsers[recordType!yourRecord.field.empid]),{})