Skip to content

shrimpza/minimum-effort-search

Repository files navigation

Minimum Effort Search

A simple REST-like service exposing some Redis Search functionality to support self-hosted full-text search functionality.

Runtime Requirements

Build

The project is built using Gradle and a Java 17 JDK:

$ ./gradlew jlinkTar

This generates a release .tgz archive in the build/ directory which may be used to run the service.

Configuration and Running

The service and index schema are configured using a simple YAML config file.

A sample file may be generated by simply running:

bin/minimum-effort-search > config.yml

The above will write the file config.yml with some example parameters which you may customise.

Thereafter, run the service with the config file as the first parameter:

bin/minimum-effort-search config.yml

The service will start up, listening on the port you specifier in the config file.

API

Add documents to the index

Add a single document:

POST /index/add

{
  "id": "1",
  "score": 1.0,
  "fields": {
    "title": "Blue T-Shirt",
    "body": "A very basic blue t-shirt you can wear",
    "price": 100,
    "url": "my.site/shirts/1",
    "tags": "shirt,blue,clothing"
  }
}

Add multiple documents:

POST /index/addBatch

[
  {
    "id": "2",
    "score": 1.0,
    "fields": {
      "title": "Jean Pant",
      ...
    }
  },
  {
    "id": "3",
    "fields": {
      "title": "Rooi Rokkie",
      ...
    }
  }
]

Search for documents in the index:

GET /search?q=shirt&limit=10&offset=0

Parameters:

  • q: Search query string
  • limit: Limit the result set to this number of documents
  • offset: Return documents starting at this offset. In combination with limit, allows for pagination through results.
{
  "docs": [
    {
      "id": "1",
      "payload": null,
      "score": 1.0,
      "fields": {
        "title": "Blue T-Shirt",
        "body": "A very basic blue t-shirt you can wear",
        "price": 100,
        "url": "my.site/shirts/1",
        "tags": "shirt,blue,clothing"
      }
    }
  ],
  "limit": 10,
  "offset": 0,
  "totalResults": 1
}

About

A simple REST service exposing some RedisSearch functionality to support simple self-hosted site search functionality.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages