Drupal 8, entityQuery with operand "AND" for a multiple values field I have 2 contents who contains a field 'field-test'. The 'field-test' contains an array of taxonomies (its a simple multiple values taxonomy field) : 

Node A : 


  field_test : '1','2','3,'4' // where 1,2,3 and 4 are tids


Node B : 


  field_test : '4','5','6,'7'


With the entityQuery api, I can get nodes who contains the taxonomy '4' OR '5' with : 

$test = \Drupal::entityQuery('node')
  -&gt;condition('field_test', array('4','5'),'IN')
  -&gt;execute();
// get nodes A and B in an array


But I want get only the node B (only the node who contains taxonomies 4 AND 5)
How can I do that ? 

Thank you :)
I'm not sure if you can do that using an entity query.

You could specify the delta explicitly:

\Drupal::entityQuery('node')
  -&gt;condition('field_tags.0.target_id', 1)
  -&gt;condition('field_tags.1.target_id', 2)
  -&gt;execute();


But of course that would only match if the ids are used in those specific deltas.

You probably need to use raw SQL for this, see https://stackoverflow.com/questions/3918351/sql-query-ensure-a-row-exists-for-each-value-in for the basic approach on how to do this.