Query with conditions on multiple documents which have same value for one field

I have data of this format in elasticsearch, each one is in seperate document:

{ 'pid': 1, 'nm' : 'tom'}, { 'pid': 1, 'nm' : 'dick''},{ 'pid': 1, 'nm' : 'harry'}, { 'pid': 2, 'nm' : 'tom'}, { 'pid': 2, 'nm' : 'harry'}, { 'pid': 3, 'nm' : 'dick'}, { 'pid': 3, 'nm' : 'harry'}, { 'pid': 4, 'nm' : 'harry'}

And I need to find the pid's which have 'harry' and do not have 'tom', which here are 3 and 4. How do I query that?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.