如何在 Meteor 中创建仅 returns 允许数据的部分搜索
How to create a partial search in Meteor that only returns permitted data
我正在尝试在 Meteor 1.8.1 中创建一个搜索功能,该功能执行以下操作:
- returns 部分匹配,例如"fish" 会找到 "fish"、"fishcake" 和 "dogfish"
- 服务器端控制return编辑哪些文档,因此搜索结果不包括未发布给用户的文档
- 相当高效
- return结果数量有限
这似乎是一个常见的要求,但我没有找到任何解决方案。
MongoDB full text search 只会 return 整个单词,所以只会找到 "fish".
据我所知,Easy search 不支持服务器端权限。
我可以尝试正则表达式解决方案,但我认为它会很昂贵?
感谢您提供任何解决方案!
编辑:从讨论来看,Easy Search 似乎支持使用选择器进行服务器端过滤,这将是最佳解决方案。但是,我无法从示例和文档中获取选择器。为了清楚起见,我创建了一个
文档明确指出,对于高级用例,您可能希望使用弹性搜索,并为您提供 pluggable extension 以减轻集成负担。
https://matteodem.github.io/meteor-easy-search/docs/recipes/#advanced-search
You might wish that a search for cafe returns documents with the text café in them (special character). Or that your search string is split up by whitespace and those terms used to search across multiple fields.
You should consider using a search engine like ElasticSearch for your search if you have these usecases. ElasticSearch allows you to configure precisely how your fields are being searched. One way you can do that is by analyzing your data, so that searching itself is as fast as possible.
我正在尝试在 Meteor 1.8.1 中创建一个搜索功能,该功能执行以下操作:
- returns 部分匹配,例如"fish" 会找到 "fish"、"fishcake" 和 "dogfish"
- 服务器端控制return编辑哪些文档,因此搜索结果不包括未发布给用户的文档
- 相当高效
- return结果数量有限
这似乎是一个常见的要求,但我没有找到任何解决方案。
MongoDB full text search 只会 return 整个单词,所以只会找到 "fish".
据我所知,Easy search 不支持服务器端权限。
我可以尝试正则表达式解决方案,但我认为它会很昂贵?
感谢您提供任何解决方案!
编辑:从讨论来看,Easy Search 似乎支持使用选择器进行服务器端过滤,这将是最佳解决方案。但是,我无法从示例和文档中获取选择器。为了清楚起见,我创建了一个
文档明确指出,对于高级用例,您可能希望使用弹性搜索,并为您提供 pluggable extension 以减轻集成负担。
https://matteodem.github.io/meteor-easy-search/docs/recipes/#advanced-search
You might wish that a search for cafe returns documents with the text café in them (special character). Or that your search string is split up by whitespace and those terms used to search across multiple fields.
You should consider using a search engine like ElasticSearch for your search if you have these usecases. ElasticSearch allows you to configure precisely how your fields are being searched. One way you can do that is by analyzing your data, so that searching itself is as fast as possible.