简体   繁体   English

Bloodhound如何适合typeahead.js?

[英]How does Bloodhound fit into typeahead.js?

I'm trying to understand how Twitters typeahead.js library works but I don't really understand what Bloodhound, the 'suggestion engine' does beyond acting as a source for the typeahead object. 我试图了解Twitter的typeahead.js库是如何工作的,但我真的不了解Bloodhound的作用,“建议引擎”除了充当typeahead对象的源代码外,还做了其他工作。

Some of my concrete questions are: 我的一些具体问题是:

  • What is a query? 什么是查询? What is a datum? 什么是基准面? What do they look like and where do I get them from 它们看起来像什么,我从哪里得到它们
  • Why do I need to tokenize my queries and datums? 为什么需要标记查询和基准?
  • What happens with the tokenized queries and datums? 标记化查询和基准会怎样?

I'd read the source code, but my Javascript is not that advanced ... The documentation is really unclear to me, as it's mostly examples and seems to be targeted at people who have implemented a typeahead in a specific way already. 我已经阅读了源代码,但是我的Javascript并不是那么高级。。。文档对我来说真的很不清楚,因为它主要是示例,而且似乎是针对已经以特定方式实现提前输入的人员。

If someone would be so kind to explain conceptually how it works I'd be very grateful. 如果有人乐于从概念上解释其工作原理,我将不胜感激。

Best regards, Joshua 最好的问候,约书亚

There is a detailed step-by-step Typeahead Tutorial @Digital Fortress with JS Fiddles to get you started with how Bloodhound and Typeahead work together. 有详细的分步式Typeahead教程@带有JS Fiddles的 Digital Fortress ,可让您开始了解Bloodhound和Typeahead的协作方式。

Here are a few extracts from the Tutorial on what I deduced: 以下是从教程中我得出的一些摘录

  • What is a query? 什么是查询? A query is the text that the user types into the text box 查询是用户在文本框中键入的文本
  • What is a datum? 什么是基准面? A datum is a single suggestion. 基准是一个建议。 (A string) (一个字符串)
  • Why do I need to tokenize my queries and datums? 为什么需要标记查询和基准? Tokenizing means to convert a string into an array of smaller strings (called tokens ). 标记化是指将字符串转换为较小字符串的数组(称为tokens )。 It is done to ease searching operation. 这样做是为了简化搜索操作。 For example, take the string "hello super man" . 例如,使用字符串“ hello super man” You can convert this string into 3 smaller strings by splitting them by the whitespace character. 您可以通过按空格字符将其拆分为3个较小的字符串。 So, "hello super man" would become ["hello","super","man"] and would ease in searching for words beginning/containing hello , super and/or man . 因此, "hello super man"将变为["hello","super","man"] ,并易于搜索以hellosuper和/或man开头/包含的单词。

  • What happens with the tokenized queries and datums? 标记化查询和基准会怎样? These are used by the Bloodhound engine to return suggestions to the user. 这些由Bloodhound引擎用来将建议返回给用户。 Bloodhound matches the queries and the datums and returns the results as suggestions to the user. Bloodhound将查询和基准相匹配,并将结果作为建议返回给用户。

Note : The official Typeahead library has NOT received any updates since 3+ years now(ref github ). 注意 :官方Typeahead库自3年以上以来没有收到任何更新(参考github )。 But there's an actively maintained fork (as of 2018) which should be used instead. 但是有一个积极维护的分叉 (截至2018年)应改为使用。

Reference 参考

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

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