How to hide the index for specific user

I think I must be missing something about your question, because that looks like a straight forward use of roles.

You create:

  • user: "user1" with roles [ "read-index1" ]
  • user: "user2" with roles [ "read-index2" ]
  • role: "read-index1" with index privileges: {"names":["index1"], "privileges":["read"]}
  • role: "read-index2" with index privileges: {"names":["index2"], "privileges":["read"]}