Discourse Algolia 搜索

:discourse2: Summary Discourse Algolia Search integrates Algolia with Discourse search.
:hammer_and_wrench: Repository Link https://github.com/discourse/discourse-algolia
:open_book: Install Guide How to install plugins in Discourse

Features

I’ve recently created a plugin that indexes topics, posts, users and tags with Algolia and combines them into a multi-category autocomplete search. Here’s a GIF of how it works:

You can find the Github repository, complete with installation instructions, on github at algolia/discourse-algolia.

Plugin configuration just requires populating a few fields. Indexing tasks are put in the jobs queue after objects are saved. Note: you will need to create an Algolia account, which is free up to 10,000 records.

Configuration

:raising_hand_woman: FAQ

Q: Does this replace the default Discourse search?
A: Only if you want it to, and right now only for the autocomplete in the header. The full search page is still reachable by hitting the enter key without a search result selected, or by using the “advanced search” link in the autocomplete footer. I say “only if you want it to” because you can enable indexing to Algolia but not affect the UI or existing Discourse search in any way - that’s why there are two checkboxes in the plugin settings. If you’re just doing indexing, you can search the data in your Algolia dashboard to see how it’s working.

Q: Do I have to pay to use the plugin?
A: It depends on how much data you have. If you have less than 1k posts, you should fit into Algolia’s free Community Plan, which gives you 10k records. A good rule of thumb is that you’ll need 10 Algolia records for each post, as posts are split up into-paragraph size chunks for optimum relevance and speed. Still, YMMV. If you’d like to use the plugin but have concerns about the cost, just send me an email and I’ll see what we can do. If you are an open source project or a non-profit, you may quality for higher limits, just fill out this form and mention Discourse.

CHANGELOG

2022.11.02

Pushed PR

  • Updated algoliasearch.js to 4.14.2
  • Updated autocomplete.js to 1.7.1

2020.09.08

Pushed 8 commits to GitHub - discourse/discourse-algolia: A plugin for indexing and searching your Discourse with Algolia

  • It should fix the bug where the search box stopped working after multiple page loads. :warning: NOTE: the plugin needs the very latest version of Discourse to work

  • The plugin is now using Discourse scss variables, and will now work correctly in Dark mode

  • Fixed a bug where user search was leading to /users instead of /u and would result in a 404. :warning: NOTE: You will need to reindex users for this to work correctly rake algolia:reindex_users

  • Fxed an alignment issue of the searchbox

  • Applied various coding standards

  • Removed part of the jquery usage

  • Searchbox should be slightly faster, as it’s now tied to rendering instead of arbitrary 100ms wait (also removed the forbidden setTimeout usage)


TODO

pr-welcome for the following tasks:

  • update algoliasearch (ruby)

This would ensure we are not deprecated in the future and allow to import libraries instead of having it in global namespace.

Last edited by @awesomerobot 2025-03-10T20:32:59Z

Check documentPerform check on document:
61 个赞

该插件似乎会自动重新索引。有人能告诉我它多久进行一次吗?我没有看到任何相关文档。
谢谢

1 个赞

除非社区里有人知道答案,否则可能要等到下周才能从 Discourse 团队那里得到答复。

我看到该插件每 5 分钟运行一次作业来处理队列中要索引的所有对象(帖子、主题、用户、标签):https://github.com/discourse/discourse-algolia/blob/main/app/jobs/scheduled/update_indexes.rb。但我不太清楚是什么原因导致对象被重新索引。

如果你有机会回复,我很想知道你看到了什么让你觉得内容被重新索引了。

1 个赞

您好 Simon,感谢您的回复!我创建了一个测试帖子。我们有一个 Algolia 账户。所以第二天我登录并搜索了该帖子,在 Algolia 管理后台中它显示出来了。我相信我在发布后立即检查时,在 Algolia 中没有看到该帖子。但我明白在索引过程中肯定会有一些延迟。5 分钟已经很不错了。我可以再发一个帖子,等待 10 分钟看看它是否在那里。我感到惊讶的是,文档中对此没有任何提及。

2 个赞

我刚开始测试这个插件。有几个问题:

  1. 当我搜索关键词时,Algolia 只列出同一主题的不同段落,而不是像 Discourse 那样显示不同的主题。除非该主题是最终答案,否则这种方法对最终用户来说似乎更具限制性和不准确性。这种行为是否应该可配置?

  2. 该插件在 Algolia 应用中创建了 3 个索引,分别对应 poststagsusers 类型。如何让该插件包含 Algolia 应用中可用的其他索引?用例:通过 Algolia 进行多站点搜索。

最后一个更像是功能请求,但我坚信第一个需要成为可配置选项,才能获得可用的搜索结果。

1 个赞

您好,

自动完成搜索在移动设备上也能使用吗?我在 Algolia 论坛上看不到它在移动设备上运行。

嘿,

Algolia 社区已不再可用,他们已迁移到 Discord

告别我们的 Discourse 论坛(以及接下来的内容)- Algolia 博客 | Algolia

此外,用户体验设计已更改。看起来更现代了。是否有计划更新插件?

并且是否可以将“登录”和“注册”按钮移动到右角(默认情况下),并将搜索栏居中,就像在“Header Search”主题组件中一样?
direita

2 个赞

目前还没有具体计划,只有极少数客户在使用此插件

3 个赞