提问人:bgfxc4 提问时间:8/21/2023 更新时间:8/21/2023 访问量:24
带有 opensearch xml 格式建议的奇怪行为
Weird behavior with suggestions in the opensearch xml format
问:
我目前正在尝试编写一个在本地评估搜索的搜索引擎。为了注册搜索引擎,我使用了 opensearch xml 文件 (https://developer.mozilla.org/en-US/docs/Web/OpenSearch)。
搜索 URL 如下所示: 。( 被缓存,以便搜索不会向服务器发出请求)http://localhost:3000/search#{searchParams}
http://localhost:3000/search
xml 文件中的搜索 url 条目如下所示:
<Url type="text/html" template="http://localhost:3000/search#{searchTerms}"/>
这完全可以正常工作,搜索工作完美无缺。
所以我尝试在搜索中添加建议。这可以通过向 xml 文件添加条目来完成。只是为了测试功能,我尝试从 Archwiki 添加一个已经工作的建议 api。我刚刚将该行从wikis xml文件复制到我的:
<Url type="application/x-suggestions+json" method="get" template="https://wiki.archlinux.org/api.php?action=opensearch&search={searchTerms}&namespace=0|3000" />
这没有用。
现在是奇怪的部分:如果我从搜索 url(而不是建议 url)中删除 建议:#
<Url type="text/html" template="http://localhost:3000/search/{searchTerms}"/>
可悲的是,这不适用于我的目的,因为像这样,每个搜索请求都会发送到服务器,这是我想阻止的。
在 Chromium 和 Firefox 中测试。
答: 暂无答案
评论