At my work, I created many pages programmatically with this document.
When I checked page searching function, those pages were not found. The cause is missing reindexing pages by the below code.
$p = Page::add($data);
$p->reindex(); // Required to be searched.
I had spent too much time finding the cause.
Programmatically create pages will use in cases like much creation at building new sites or renewal, etc.