SearchPlugin: suggestions neos_path frontend

Hi there,

can someone give me hint, what I’m doing with a “neos_path” inside the frontend context?

I’m using ElasticSearch with the SearchPlugin and using both the “completions” and the “suggestions” function.

Technically everything works. But I stuck that the ajax request is giving me back a neos_path instead an URI for “suggestions”:

'neos_path' (9) => '/sites/my-side/node-nys329nw3qulr/node-b3pwg0v7pbrov' (63)
   'title' (5) => 'Some title' (10)

Generally it’s not uncommon to me, that I would have to add the URI to the index in advance. For TYPO3 solr as example I write some TypoScript for the URI at point X and that’s all.

But when the SearchPlugin already delivers the neos_path, there must be another point of view.

Kind regards,

Maximilian

Did really no one has a hint for this issue? I consider more options to handle that. But still don’t get it what to do with “neos_path” inside frontend (javascript; ajax). I have to assume, that I simply don’t understand a main point of it all (the neos_path? The routing? The search configuration?). I can’t explain it any other way, because it seems that I’m the only one with that problem.

Inside the ReadMe of Flowpack.SearchPlugin simply stands:

These can be used to provide autocompletion on the search input using a JS library of your choice.

I do. But the neos_path itself produce a 404. Beside the fact, that I don’t want to show internal node IDs inside the frontend.

Any help to understand it better?

It’s been a while that I used those the last time. But check out Flowpack.SearchPlugin/Settings.yaml at master · Flowpack/Flowpack.SearchPlugin · GitHub

There you see which fields are configured for the suggestions. You can add your own fields too, which you previously indexed. So to make the suggestions contain valid urls you need an indexing helper that generates and stores the required Uris with the indexed document.

I remember building all this with @daniellienert but I don’t remember anymore whether we put this helper into some package, or why we left it out.

Okay thank you, I already have used that configuration for some tests. Works fine with custom properties.

If this is the way, thats an helpful information. So I will simply ignore the “neos_path”. Thank you.

I recommend removing it, if you don’t need it.
Maybe we just put it there for testing purposes. Sorry for the limited documentation…

If you find a good solution maybe you can update the docs?

Why not, I’m on it as fast as I can :slight_smile:

1 Like

The solution for interested developer:

It’s tricky to build an own URI Helper inside the backend context while indexing, because the UriBuilder always need a (controller) context. At first I got only backend-urls. But then I saw there is already a solution out there.

Use this: GitHub - punktDe/outofbandrendering: Supplies an EelHelper to do out of band rendering of fusion objects.

With the help of the OutOfBandRendering extension it’s possible to use some fusion code with a given node. The extension is adding the context by itself to get it work.

The “magic” inside YAML:

properties:
    'neos_node_uri':
      search:
        elasticSearchMapping:
          type: keyword
        indexing: '${FusionRendering.render(node, "searchUriHelper")}'

And the other part inside fusion:

searchUriHelper = MY.Website:Content.NodeLink

The “MY.Website:Content.NodeLink” fusion prototype should be self explained. If not, it’s simply like this without HTML tags inside the afx-rendering:
https://docs.neos.io/cms/manual/rendering/link-fusion-objects#neos-neos-nodeuri

And how @sebobo already mentioned above, we have to override the searchPlugin settings like this

Flowpack:
  SearchPlugin:
    searchAsYouType:
      autocomplete:
        size: 10
        enabled: true
      suggestions:
        size: 10
        enabled: true
        sourceFields:
          - title
          - neos_node_uri

If someone should struggle with something, feel free to ask. But all in all NEOS and it’s lead developer already deliver all we need to solve it.

1 Like