A Redis-based ordered autocomplete service.
This is a public endpoint that accepts a single query parameter, q,
and returns JSON-encoded search results.
| Example query | Status | Example response | Description |
|---|---|---|---|
/search?q=ta |
200 | [["tag", 5], ["second tag", 3]] |
search for a given query yielded several results (the response includes first ten, ordered by score) |
/search?q=sth |
200 | [] |
search for a given query yielded no results |
/search |
400 | (empty) | no query was given |
This endpoint increments and decrements scores for given tags.
Tags with score less than or equal to zero are not included in search results, and tags that were not present before are created with an initial score of 1.
Accepted POST parameters are add, remove, or both. They should
contain JSON-encoded arrays of tag names; names can be repeated (in
that case, the score gets incremented/decremented several times).
The endpoint responds with OK 200 in case of a successful update.
Example queries:
curl -XPOST -d 'add=["tag one", "tag two"]' localhost:3030/update
curl -XPOST -d 'remove=["tag one", "tag two"]' localhost:3030/update
curl -XPOST -d 'add=["tag three"]&remove=["tag four"]' localhost:3030/updatePull from littlebobbytables/sapphire.
There are several ways to connect the application to Redis:
# With an instance of Redis running on host's port 6379:
docker run --net=host littlebobbytables/sapphire
# With an instance of Redis running inside a Docker network on port 6379:
docker run --network=network -p 3030:3030 -e REDIS_HOST=redis_host littlebobbytables/sapphire
# You can try out the latter approach with Docker Compose (see docker-compose.yml):
docker run --network=sapphire_redis-network -it -p 3030:3030 -e REDIS_HOST="redis" littlebobbytables/sapphirestack docker pull
stack builddocker-compose run
stack test