• Home
  • Categories
  • Recent
  • Popular
  • Pricing
  • Contact us
  • Docs
  • Login
FusionAuth
  • Home
  • Categories
  • Recent
  • Popular
  • Pricing
  • Contact us
  • Docs
  • Login

Retrieving groups of users

Scheduled Pinned Locked Moved
Q&A
groups search
1
3
1.2k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D
    dan
    last edited by 22 Jul 2020, 15:26

    I need to retrieve all users that are (examples) employees or residents via API. In the docs I've found that I can for example create such roles and assign users the according role. Or, I can create such groups and make users members of the according group. Yet I'm still scratching my head on how to exactly retrieve those users. I've found that using Elasticsearch (using the User Search APIs) I can create a query that retrieves the users. Is there maybe a simpler way that I'm missing? E.g. in https://fusionauth.io/docs/v1/tech/core-concepts/groups it says "Once a User is a member of a Group they may be identified as a member of the Group and retrieved using the Group APIs.", but I've not found how I can retrieve that user using the the Group APIs. Pointers highly appreciated, thanks

    --
    FusionAuth - Auth for devs, built by devs.
    https://fusionauth.io

    1 Reply Last reply Reply Quote 0
    • D
      dan
      last edited by 22 Jul 2020, 15:28

      If you use the search in the UI and open the ‘Advanced’ search controls you can search by group or application role. If you then click Show Elasticsearch query you’ll see how we are performing this search query.

      Using the API (as long as you are using the elasticsearch search engine) you can utilize the Elasticsearch Query String Query DSL, or a full JSON search query object.

      Example, to query by group membership where the group Id is 8e9225f9-6286-4bbb-9d4b-f75228018386, you'd use a queryString of:

      memberships.groupId:8e9225f9-6286-4bbb-9d4b-f75228018386
      

      The groups API doc you reference is incorrect; we'll need to fix that.

      --
      FusionAuth - Auth for devs, built by devs.
      https://fusionauth.io

      1 Reply Last reply Reply Quote 0
      • D
        dan
        last edited by 22 Jul 2020, 15:53

        Fix is live: https://github.com/FusionAuth/fusionauth-site/pull/147

        --
        FusionAuth - Auth for devs, built by devs.
        https://fusionauth.io

        1 Reply Last reply Reply Quote 0
        3 out of 3
        • First post
          3/3
          Last post