[SOLVED] JSON-API: Search in HTML content

Hey guys,

I’m currently implementing a JSON-API in PHP. I need a text search in blog articles, so ultimately I need to search the HTML content of the articles too. Currently I’m using this approach: I get the Blog-Articles with a FlowQuery (in PHP) and fetch the HTML of the Main-Content-Collection like this:

private function fetchMainContentHtml(NodeInterface $node): string {
        $main = $node->getPrimaryChildNode();
        $context = $this->getControllerContext();
        $view = new FusionView();
        $view->assign('value', $main);
        $view->setFusionPath('page<Neos.NodeTypes:Page>/body<My.News:NewsPage>/content/main<Neos.Neos:PrimaryContent>', $context);
        return $view->render();

If you do this with 1000 nodes it would be very slow (>4 sec per request). Is it possible to do this in a better way without caching?

The problem with caching is invalidating the cache after a change to the content has been made, which I still didn’t quite figure out.

Why would you need to search the markup? Why not search the content? We have solutions to that with SimpleSearch and ElasticSearch.

1 Like

Thanks for the hint, I will look into that.