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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With