概念
ZincSearch 是一个搜索引擎,当您在 ZincSearch 中上传数据后,您就可以搜索自己的数据。可以把它想象成 “Google” 或 “Bing” 搜索,但只是针对您自己的数据。
ZincSearch 允许你对你的 (json) 文档进行索引,并允许进行全文搜索。
比如,当你插入数据:
{"message":"Prabhat Sharma is a cool guy to hang with."}
还有更多类似上述的文档,然后搜索 Prabhat、cool 或任何词或词的组合。
ZincSearch Index - ZincSearch 索引
索引是 ZincSearch 存储你推送给它的数据的起来,以便加速访问。ZincSearch为数据维护倒排索引。
倒排索引 - Inverted Index
倒排索引是一种数据库索引,它存储了从内容(如单词或数字)到其在表中、或在一个文档或一组文档中的位置的映射。倒排索引的目的是允许快速的全文搜索,但代价是当一个文件被添加到数据库中时需要额外处理。
例如,一组文档的倒置索引可能看起来像:
{"id":1, "message: "Prabhat Sharma is a cool guy to hang with"}
{"id":2, "message: "Prabhat Sharma is in San Francisco"}
| Message | 文档 ID |
|---|---|
| Prabhat | 1, 2 |
| Sharma | 1, 2 |
| cool | 1 |
| guy | 1 |
| hang | 1 |
| with | 1 |
| San | 2 |
| Francisco | 2 |
Bluge
Bluge 是 ZincSearch 使用的底层索引库,它在此基础上提供了大量的功能。
Index mapping
一个文档可以有多个字段。每个字段都可以有一个类型。一个映射定义了哪些字段有什么类型的索引。映射允许 ZincSearch 对文档进行正确的索引。如果一个字段没有映射,那么 ZincSearch 就使用反射来寻找它的类型。
比如,olympics 索引的 mapping 可以是这样的
{"mappings": {"properties": {"Athlete": {"type": "text"},"City": {"type": "keyword"},"Country": {"type": "keyword"},"Discipline": {"type": "text"},"Event": {"type": "text"},"Gender": {"type": "text"},"Medal": {"type": "keyword"},"Season": {"type": "keyword"},"Sport": {"type": "text"},"Year": {"type": "numeric"}}}}
