Simone Fumagalli writes:
*Items returned are not unique. I see "Armani" is in the first and in
the second result set. Is there a way to avoid duplicated results ?
I would recommend you check out the recently released field collapsing
feature for de-duplicating results based on a field:
*I see you specified the "size": 5 in the last query but I don't have
this parameter. I want a maximum of 10 items from the first query and
a maximum of 5 from the second one and 20 results in total. This means
that if the first query returns 3 items (because there aren't other
items that match the query) the second one return 5 I want the third
one to return 12 items (20 - (3+5))
Okay, in this case, you have a couple of options.
-
Do each individual query, so that you know the total number of hits
and can adjust the third query if the first one only returned 3 hits. -
Return more hits than necessary from each query and display only what
is needed on the client side. So you'd ask for 20 hits from each of the
three queries, but only display [10, 5, 5], [3, 4, 13], or [0, 0, 20]
etc.
If you want to do the queries in a single request, then option #2 is the
way to go.