Drupal v. 9.3.8 I recently used the entityQuery command and for simpler queries I had no problems. Now I need to filter, as well as for the '=' and 'IN' operators, also the nodes, whose multivalued field has no values or which does not have certain values. Reading the documentation I used the 'NOT IN' operator, but with poor results. Example the query should return me the nodes that do not have the value 161 and 163 This is the query I simplified to try the 'NOT IN' operator
$nids = \Drupal::entityTypeManager()->getStorage('node')->getQuery()
->condition('type' , 'gestione' )
->notExists('field_attivita')
->condition( 'field_attivita', ['161', '163'], 'NOT IN' )
->execute();
I also tried with the '<>' operator but nothing to do
Among the various articles and questions I also read the post that comes close to my request How to use entityQuery to select if a multiple value entityReference field does not contain the id but I can't understand why it doesn't work