• Home
  • Categories
  • Recent
  • Popular
  • Pricing
  • Contact us
  • Docs
  • Login
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
3.0k
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 3 Aug 2020, 20:43

    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
    • D
      dan
      last edited by 3 Aug 2020, 20:47

      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
      1 out of 2
      • First post
        1/2
        Last post