Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bulk query in Elastic search

We have a database of 1 Million records, and we would like to query list of emails using UserID's.

What's the best way to do it in Elastic search. We don't want to loop individual UID and get respective email. If we can get all emails with one bulk search that would be great.

Any ideas are welcome.

like image 922
Vishnu Vankayala Avatar asked Jan 28 '26 03:01

Vishnu Vankayala


1 Answers

You can try like this.

POST localhost:9200/users/user/_search?pretty=true
{
    "_source": "email",
    "query" : {
        "match" : { "userId" : "abc123" }
    }
}

or

POST localhost:9200/users/user/_search?pretty=true
{  
    "query" : {
            "match" : { "userId":"abc123" }
        },
        "fields": ["email"]
}

I recommend first one.

like image 118
Rahul Avatar answered Jan 29 '26 20:01

Rahul