Hi All,
At the company I work for we are evaluating ES to replace certain type of
queries that we run now on DB. On database we have more than 40k tables and
we run queries like this one.
SELECT
t1.user_id
FROM
table1 t1 join table2 t2 on t1.user_id = t2.user_id
WHERE
t1.name like "%am%"
AND t2.followers_count>1;
For that query we need the user_id and the number of users affected (count).
On ES I've created an index with an extra field that contains the table
name, and I've managed to write the query like that:
{
"query": {
"bool": {
"should": [
{
"terms": {
"table_name": [ "t1" ],
"minimum_should_match": 1
}
},
{
"terms": {
"table_name": [ "t2" ],
"minimum_should_match": 1
}
}
]
}
},
"size": 0,
"aggs" : {
"user_ids": {
"terms" : {
"field" : "user_id",
"min_doc_count": 2
}
}
}
}
The problem I'm facing here is that I cannot get the number of user user_id
affected. I get the user_ids as an aggregate, but I couldn't find the way
to get the number of them. I've tried to get the count on the client side,
but sometimes that list can get really big (millions) so it's quite a waste
of memory.
Any help? Is there a better way to do that?
Thanks,
Isart Montane Mogas
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/05ecf5f0-6313-4ee4-84a7-d36c0cc844ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.