简体   繁体   English

Aerospike自动完成

[英]Aerospike autocompletion

I want to implement an autocompletion mechanism for aerospike but I don't how I cando it .Is it possible to make an autocompletion mechanism with aerospike? 我想为aerospike实现一个自动完成机制,但我不知道如何使用它。是否可以使用aerospike制作自动完成机制? If yes how can it be implemented? 如果是,如何实施?

Basically, you need functionality to do prefix matching on strings. 基本上,您需要在字符串上进行前缀匹配的功能。 Aerospike is primarily a key-value store which additionally supports secondary index queries. Aerospike主要是一个键值存储,它还支持二级索引查询。 The secondary index query in Aerospike does not yet support prefix matching of strings. Aerospike中的二级索引查询尚不支持字符串的前缀匹配。 When this is supported, you can use Aerospike for your use case. 如果支持此功能,您可以将Aerospike用于您的用例。

Already deployed one with existing feature set. 已经部署了一个具有现有功能集。 It works roughly like this: 它的工作方式大致如下:

Autocomplete-Feature with Aerospike: Aerospike自动完成功能:

  1. Decide on a trigger count of characters (eg 3, 'prefixlength') 确定字符的触发计数(例如3,'prefixlength')
  2. Filter any input to get only ascii characters (no é,ä,ü,..), trim all whitespaces and transform to lowercase. 过滤任何输入以仅获取ascii字符(无é,ä,ü,..),修剪所有空格并转换为小写。
  3. Create records for all possible combinations from "Autocomplete_aaa" to "Autocomplete_zzz", each with a list (would use large ordered list to be on the safe side) OR handle not existing records in your query-logic. 创建从“Autocomplete_aaa”到“Autocomplete_zzz”的所有可能组合的记录,每个组合都有一个列表(将使用大型有序列表在安全方面) 处理查询逻辑中不存在的记录。
  4. In each list, gather all strings you want to propose when the prefix is entered. 在每个列表中,收集输入前缀时要提议的所有字符串。
  5. Anytime a user enters something, cut it to prefixlength and just query the record 'Autocomplete_car' for it to propose 'cars', 'car repair', and so on. 无论何时用户输入内容,将其剪切为前缀长度,只需查询记录'Autocomplete_car',即可提出“汽车”,“汽车修理”等信息。
  6. From now on just use that list to filter further on the client side (eg javascript). 从现在开始,只需使用该列表进一步在客户端进行过滤(例如javascript)。

The main takeaway from this is that you will have to reduce both your results and your search terms to the same identifying token (here 3 ascii characters) that will act as your primary key for records. 这样做的主要内容是,您必须将结果和搜索条件减少到相同的识别标记(此处为3个ascii字符),这些标记将作为记录的主键。

Note: this won't scale indefinetely in terms of list size. 注意:就列表大小而言,这不会无限缩放。 You need to choose your prefix-length carefully, so there ain't too many proposals that need to be read from db and transfered to the client but also watch out for Aerospike's max record size if not using an large, infinitely scalable data type like the large list. 您需要仔细选择前缀长度,因此没有太多的提案需要从db读取并转移到客户端,但如果不使用大型,无限可扩展的数据类型,也要注意Aerospike的最大记录大小大清单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM