Load all titles and body text from one content type into array I'm working on an input format filter that should work as following. I have a content-type called glossary, the user can fill in a word (title) and description (body). Then there is a content-type article. When a word in the article matches a word in the glossary it should wrap that word with a span. Something like word. I already did a quick and dirty tryout and that worked fine. I already did a speed test and it worked out fine only a delay of 0.2s max.
But now I try to make it as it should and I got stuck.

The way I think this could work is to have an array with all words and descriptions from the glossary content-type in a array. And then search through the text.

So I created a Plugin/Filter/Filtername.php file. In this file I try to load all node from the glossary content-type (as advised) via dependency injection.

What I found is a way to get all nids, via this code added in to my filter class:

class FilterName extends FilterBase {
    public function __construct(QueryFactory $entity_query)
    {
        $this-&gt;entity_query = $entity_query;
    }

    public static function create(ContainerInterface $container){
        return new static(
          $container-&gt;get('entity.query')
        );
    }

    public function process(){
        $query = $this-&gt;entity_query
        $query-&gt;condition('bundle','woordenlijst');
        $nids = $query-&gt;execute();
    }
}


So this should give me all nids of the node I'm looking for but how do I get these node loaded to get there title and body text? I found this lesson about entity loading. Which is usefull but there are some deprecated functions used and I have no idea how to combine these to to get een array of titles and body texts.

So what is currently the best method to load nodes and how can I combine this with the code I already have? And am I even on the right path or not, or is there a better/easier way to do this?

Thanks in advance.
If yau have lots of node's than its difficult load all nodes at a time and also , to get only title and body, its not fair to load complete node.
Rather than load node and get values, we can use select query and fetch required values.

I am using cache concept here, once your query loaded, set it in cache untill any node values changes or any new node creates.
Use node hooks to remove cache for "node_data"
Below is the query:

  $nodedata = array();
  // Check cache exists
  $cache_node = \Drupal::cache()-&gt;get('node_data');
  if ($cache_node) {
    $array = $cache_node-&gt;data;
    $nodedata = json_decode($array, TRUE);
  }
  else {
    // Query for node title and body.
    $connection = \Drupal::database();
    $query = $connection-&gt;select('node', 'n');
    $query-&gt;leftJoin('node__body', 'b', 'b.entity_id = n.nid');
    $query-&gt;leftJoin('node_field_data', 't', 't.nid = n.nid');
    $query-&gt;fields('t', array('title'));
    $query-&gt;fields('b', array('body_value'));
    $query-&gt;condition('n.type', 'glossary', '=');
    $result = $query-&gt;execute()-&gt;fetchAll();
    foreach ($result as $key =&gt; $value) {
      $nodedata[] = array(
        'node_title' =&gt; $value-&gt;title,
        'node_body' =&gt; $value-&gt;body_value,
      );
    }
    // Set Cache.
    \Drupal::cache()-&gt;set('node_data', json_encode($nodedata));
  }
  dsm($nodedata);