Typesense: Open-Source Alternative to Algolia

栏目: IT技术 · 发布时间: 4年前

内容简介:Typesense is a fast, typo-tolerant search engine for building delightful search experiences.

Typesense: Open-Source Alternative to Algolia

Typesense is a fast, typo-tolerant search engine for building delightful search experiences.

Typesense: Open-Source Alternative to Algolia

Menu

Features

  • Typo tolerant: Handles typographical errors elegantly.
  • Simple and delightful: Simple to set-up and manage.
  • Tunable ranking: Easy to tailor your search results to perfection.
  • Fast: Meticulously designed and optimized for speed.

Install

You can download the binary packages that we publish for Linux (x86-64) and Mac.

You can also run Typesense from our official Docker image :

Quick Start

Here's a quick example showcasing how you can create a collection, index a document and search it on Typesense.

Let's begin by starting the Typesense server via Docker:

docker run -p 8108:8108 -v/tmp/data:/data typesense/typesense:0.11.1 --data-dir /data --api-key=Hu52dwsas2AdxdE

Install the Python client for Typesense (we have clients for other languages too):

pip install typesense

We can now initialize the client and create a companies collection:

import typesense

client = typesense.Client({
  'master_node': {
    'host': 'localhost',
    'port': '8108',
    'protocol': 'http',
    'api_key': 'Hu52dwsas2AdxdE'
  },
  'timeout_seconds': 2
})

create_response = client.collections.create({
  "name": "companies",
  "fields": [
    {"name": "company_name", "type": "string" },
    {"name": "num_employees", "type": "int32" },
    {"name": "country", "type": "string", "facet": True }
  ],
  "default_sorting_field": "num_employees"
})

Now, let's add a document to the collection we just created:

document = {
 "id": "124",
 "company_name": "Stark Industries",
 "num_employees": 5215,
 "country": "USA"
}

client.collections['companies'].documents.create(document)

Finally, let's search for the document we just indexed:

search_parameters = {
  'q'         : 'stork',
  'query_by'  : 'company_name',
  'filter_by' : 'num_employees:>100',
  'sort_by'   : 'num_employees:desc'
}

client.collections['companies'].documents.search(search_parameters)

Did you notice the typo in the query text?No big deal. Typesense handles typographic errors out-of-the-box!

Detailed Guide

A detailed guide is available on Typesense website .

Build from source

Building with Docker

The docker build script takes care of all required dependencies, so it's the easiest way to build Typesense:

TYPESENSE_VERSION=nightly ./docker-build.sh --build-deploy-image --create-binary [--clean] [--depclean]

Building on your machine

Typesense requires the following dependencies:

  • C++11 compatible compiler (GCC >= 4.9.0, Apple Clang >= 8.0, Clang >= 3.9.0)
  • Snappy
  • zlib
  • OpenSSL (>=1.0.2)
  • curl
  • ICU
./build.sh --create-binary [--clean] [--depclean]

The first build will take some time since other third-party libraries are pulled and built as part of the build process.

FAQ

How does this differ from using Elasticsearch?

Elasticsearch is better suited for larger teams who have the bandwidth to administer, scale and fine-tune it and especially when have a need to store billions of documents and scale horizontally.

Typesense is built specifically for decreasing the "time to market" for a delightful search experience. This means focussing on developer productivity and experience with a clean API, clear semantics and smart defaults so that it just works without turning many knobs.

Speed is great, but what about the memory footprint?

A fresh Typesense server will take less than 5 MB of memory. As you start indexing documents, the memory use will increase correspondingly. How much it increases depends on the number and type of fields you index.

We've strived to keep the in-memory data structures lean. To give you a rough idea: when 1 million Hacker News titles are indexed along with their points, Typesense consumes 165 MB of memory. The same size of that data on disk in JSON format is 88 MB. We hope to add better benchmarks on a variety of different data sets soon. In the mean time, if you have any numbers from your own datasets, please send us a PR!

Help

If you've any questions or run into any problems, please create a Github issue and we'll try our best to help.

© 2016-2019 Typesense Inc.


以上所述就是小编给大家介绍的《Typesense: Open-Source Alternative to Algolia》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

C语言从入门到精通

C语言从入门到精通

王娣//韩旭 / 清华大学 / 2010-7 / 49.80元

《C语言从入门到精通》从初学者的角度出发,以通俗易懂的语言,丰富多彩的实例,详细介绍了使用C语言进行程序开发应该掌握的各方面知识。全书共分17章,包括C语言概述,算法,数据类型,运算符与表达式,常用的数据输入、输出函数,选择结构程序设计,循环控制,数组,函数,指针,结构体和共用体,位运算,预处理,文件,存储管理,网络套接字编程和学生成绩管理系统等。所有知识都结合具体实例进行介绍,涉及的程序代码给出......一起来看看 《C语言从入门到精通》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具