redis-field-engineering / redis-graphql

GraphQL Service for Redisearch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GraphQL-Redis

A GraphQL server backed by Redis

Features

  • Query Redis data using GraphQL
  • Full text search on fields in Redis Data
  • Numeric range queries
  • Negative and optional matches
  • Aggregate data for reporting
  • Geographic matching
  • Only minimal configuration required

How this works

The GraphQL server queries RediSearch for the search schema then dynamically builds the GraphQL schema.

img

Data Formatting

Data is stored in a Redis Hash data structure

For example we have a list of gaming users and we want to be able to search these users by fields

user:jennifer82

Field Example Value
username jennifer82
location 41.09822,120.74792
rating 591
playstyle stationary,sniper
email jennifer.lewis@example.com
HSET user:jennifer82 username jennifer82  rating 591  email jennifer.lewis@example.com playstyle stationary,sniper location 122.4194,37.7749

Create an Index on the fields you wish to search

FT.CREATE Gamers ON HASH PREFIX 1 user: SCHEMA username TEXT location GEO SORTABLE rating NUMERIC SORTABLE playstyle TAG email TAG

Note: Please do not use : or - in the Index name. _ is acceptable.

See Tips and Tricks for more detailed information on creating a Redisearch schema

Run the GraphQL server and point at the the Redis instance

./redis-graphql --redis-host localhost --redis-port 6379

View the auto generated documents in browser

http://localhost:8080/docs

Run a query

curl -s -X POST  -H "Content-Type: application/json" --data '{"query": "{ Gamers(username:\"jennifer82\") {username,email,rating}}"}'   http://localhost:8080/graphql 
{
  "data": {
    "Gamers": [
      {
        "email": "jennifer.lewis@example.com",
        "rating": 591,
        "username": "jennifer82"
      }
    ]
  }
}

See Querying and Aggregations for more detailed query examples

Utilities

Example Prometheus/Grafana Setup is available

About

GraphQL Service for Redisearch

License:Other


Languages

Language:Go 81.4%Language:Python 13.5%Language:Shell 3.2%Language:Makefile 0.9%Language:Dockerfile 0.5%Language:Lua 0.5%