Weird behavior with suggestions in the opensearch xml format

65 views Asked by At

I am currently trying to write a search engine that evaluates the search locally. To register the search engine I am using the opensearch xml file (https://developer.mozilla.org/en-US/docs/Web/OpenSearch).

The search url looks like this: http://localhost:3000/search#{searchParams}. (http://localhost:3000/search is cached, so that a search does not make a request to the server)

The search url entry in the xml file looks like this:

<Url type="text/html" template="http://localhost:3000/search#{searchTerms}"/>

This works completely fine and the search works flawlessly.

So I tried to add suggestions to the search. This can be done by adding an entry to the xml file. Just to test the functionality, I tried adding an already working suggestions api from the Archwiki. I just copied the line from the wikis xml file to mine:

<Url type="application/x-suggestions+json" method="get" template="https://wiki.archlinux.org/api.php?action=opensearch&amp;search={searchTerms}&amp;namespace=0|3000" />

Which did not work.

Now for the weird part: If I remove the # from the search url (not the suggestions url), the suggestions work:

<Url type="text/html" template="http://localhost:3000/search/{searchTerms}"/>

Sadly, this will not work for my purpose, because like this, every search request will be sent to the server, which I want to prevent.

Tested in Chromium and Firefox.

0

There are 0 answers