Portal - Full Text Search Web Service

crates.io

Purpose

The purpose of this service is to be your full text search web service for any JSON client including JavaScript front-ends like React with fetch.

Portal is a competitor to ElasticSearch, MeiliSearch, AWS CloudSearch, AWS ElasticSearch Service, and Algolia.

Portal is built to be simple and blazing fast with JWT verification, indexing, deindexing, search, and word suggest.

Indexing is batch indexing by default.

To use this service you need to have a running sonic server and a broker server.

Features

Use

  1. create a user on broker with the following scopes - for full permissions portal:full or granular permissions portal:index, portal:deindex, portal:search, or portal:suggest
  2. login to broker and get a JWT
  3. attach the JWT as an Authorization: Bearer {token} to the following JSON API endpoints

Index

html POST /index - authenticated endpoint (Authorization: Bearer {jwt}) example: json { "items": [{ "collection": "coffee", "bucket": "tenant_1", "id": "49e28aae-88d4-4c19-86d8-51f2c9f11039", "data": { "name": "roasted", "image": "https://img.com/bucket/123/123.jpg" }, "locale": "eng", "indexes": ["name"] }] } will return: 200 or 500 or 400 or 401

Search

html POST /search - authenticated endpoint (Authorization: Bearer {jwt}) json { "collection": "coffee", "bucket": "tenant_1", "query": "roasted", "limit": 10, "offset": 10 } - note: limit and offset are optional fields

will return: 200 or 500 or 400 or 401

200 - will return an array of objects json [ { "collection": "coffee", "bucket": "tenant_1", "id": "49e28aae-88d4-4c19-86d8-51f2c9f11039", "data": { "name": "roasted", "image": "https://img.com/bucket/123/123.jpg" }, "locale": "eng", "indexes": ["name"] } ]

Word Suggest

html POST /suggest - authenticated endpoint (Authorization: Bearer {jwt}) json { "collection": "coffee", "bucket": "tenant_1", "query": "r", "limit": 10 } - note: limit is an optional field

will return: 200 or 500 or 400 or 401

json { "suggestions": ["roasted"] }

Deindex

html POST /deindex - authenticated endpoint (Authorization: Bearer {jwt}) json { "ids": ["49e28aae-88d4-4c19-86d8-51f2c9f11039"] }

will return: 200 or 500 or 400 or 401

Health Check

html GET or HEAD / - public endpoint

will return: 200

Install

cargo install portal

Service

There is an example systemctl service for Ubuntu called portal.service in the code

TechStack

Inspiration