0

I have two indexes: Services and Messages. The both have field "ItemId".

I want to get a result that contains intersection of the both searches that return ItemId field.

[1,3,5] and [1,6,8] => I need only [1]

If I get the first result and then the second one and only after that intersect the arrays I get nothing because each result returns only limited count of hits.

[1,45,789] and [234,54,3] => I get nothing

1 Answers1

0

All you need to do is to target multiple indexes for a given query.

So for example: For the given two indexes Services and Messages your query will look something like this:

GET Services,Messages/_search
{
    "query":{
        "match_all":{}
    }
}

Note that I have targeted the two indexes while making search request.

You can write the corresponding code in NEST or any other client.

Nishant
  • 7,504
  • 1
  • 21
  • 34
  • I dont thinck this is what is look about (he already know to querry different index i thincl). He should explain better his question, with a true example. But i thinck he want to know if he can have intersection of differents doc in 2 index in 1 querry. According to his data (are the number unique?) we could give an answer, as if i thinck the answer is : "no, should be done on client side and yes, would be performance issue if you have a lots of data", so please post your data, mappings and how you build your index, maybe the modélisation could be better. – LeBigCat Dec 24 '18 at 11:58
  • @LeBigCat I agree to your point. Since the question was not clear enough I gave the answer so that he/she may get a direction. – Nishant Dec 24 '18 at 14:17