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

    How can I find all users except one?

    Scheduled Pinned Locked Moved
    Q&A
    elasticsearch bulk delete query
    1
    2
    2.9k
    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.
    • danD
      dan
      last edited by

      I want to delete all the users in the system except one. I know I can use the bulk delete functionality, but how can I exclude just one user?

      I am using the elasticsearch search engine.

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

      1 Reply Last reply Reply Quote 0
      • danD
        dan
        last edited by

        You can use the admin ui to build the query string.

        Definitely test it out with the search first, and then use the bulk delete api.

        Here's a shell script that searches for all users except one:

        curl -vvv -XGET -H "Authorization: $API_KEY" 'http://localhost:9011/api/user/search/?queryString=NOT%20email:test%40example.com'
        

        Note that I had to escape the space and the @ sign, but here's the elasticsearch query without the escaping: NOT email:test@example.com.

        Also, if you are using the database search engine, the syntax will be entirely different, as this example relies on the Elasticsearch syntax.

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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post