I'm experimenting with how to customize an auto-complete field.
Filter the nodes in bae to various parameters
The code is this
$storage = \Drupal::entityTypeManager()->getStorage('node');
$qry = $storage->getQuery()
->condition( 'type', 'anagrafica_richiedenti' )
->condition('status', 1)
->condition('field_attivo', 1)
->sort( 'title', 'ASC' )
->execute();