使用 java、Redis、Elastic Search、Mongo 自动完成 [英] Autocomplete with java , Redis, Elastic Search , Mongo

查看:32
本文介绍了使用 java、Redis、Elastic Search、Mongo 自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须实现一个包含超过 500,000 个名称的自动完成功能,这些名称以后可能会增加到超过 400 万个.

Backend 是一个使用 Spring 的 java REST web 服务调用.我应该使用 MongoDBRedis 还是 Elasticsearch 来存储和查询/搜索名称?

解决方案

这是一个关键的搜索用例,MongoDB 和 Redis 非常适合基于键的查找,而不是用于搜索目的,而 Elasticsearch 是一个分布式搜索引擎,专为此类用例构建.

在选择系统之前,您应该了解您的功能在内部是如何工作的,以及选择它的考虑因素.

您的功能的非功能性要求

  1. 每秒搜索查询总数 (QPS) 是多少?
  2. 您多久更新一次文档(即示例中的名称).
  3. 名称更新并进入搜索结果后的 SLA 是什么?
  4. 搜索结果的 SLA.

一些功能需求.

  1. 自动完成的名称、前缀、中缀搜索应该是什么样的?
  2. 在向他们显示自动完成结果之前,用户应该输入的最少字符数.
  3. 上述要求多久更改一次.

<块引用>

Elasticsearch 在倒排索引中索引文档并在令牌匹配(可以轻松定制以适应业务要求),因此搜索速度非常快.Redis 和 MongoDB 是内部没有这个结构,不应该用于这个用例.你不应该对选择 Elasticsearch 有任何疑问这些来实现自动完成.

I have to implement an autocomplete with over 500,000 names which may later increase to over 4 million names.

Backend is a java REST web service call using Spring. Should I use MongoDB, Redis or Elasticsearch for storing and querying/searching the names?

解决方案

It's a critical search use case, and MongoDB and Redis are perfect for key-based lookups and not use for Search purposes, while Elasticsearch is a distributed search engine, built specifically for such use-case.

Before choosing the system, you should know how your feature works internally And below the consideration for selecting it.

Non-functional requirements for your feature

  1. What would be the total no of search queries per second (QPS)?
  2. How frequently you would be updating the documents(ie, names in your example).
  3. What is the SLA after names in updated and coming in the search result?
  4. SLA for your search results.

Some functional requirements.

  1. How autocomplete should look like, prefix, infix search on names?
  2. Minimum how many character user should type, before showing them the autocomplete results.
  3. How frequently the above requirements can change.

Elasticsearch indexed documents in the inverted index and works on tokens match(which can be easily customized to suit business requirements), hence super fast in searching. Redis and MongoDB are not having this structure internally and shouldn't be used for this use-case. You shouldn't have any doubt about choosing Elasticsearch over these to implement Autocomplete.

这篇关于使用 java、Redis、Elastic Search、Mongo 自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆