maxmclau / fuzzy-service

Lambda based fuzzy matching function with mutable terms dictionary

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

λ Fuzzy Service

Built for SumUp

Lambda based fuzzy matching function with mutable terms dictionary

Installation

Deployment and development of the function requires serverless & dep.

$ npm install -g serverless

On Mac, installing dep would look something like this.

$ brew install dep

Build

$ make build

Deploy

$ make deploy
$ make deploy-prod

API

Detailed request and response information for API

GET /match

Return all matched terms against dictionary

GET /prod/match?q=Ammo& q=I sell ammunition HTTP/1.1
200 OK - Response
[
    {
        "query": "Ammo",
        "terms": [
            "Ammo",
            "Ammunition"
        ]
    }
]
GET /prod/match?q=Puppies& q=I sell puppies HTTP/1.1
204 No Content - Response
...

GET /terms

Return all terms used in fuzzy matching along with the date they were last modified

GET /prod/terms HTTP/1.1
200 OK - Response
{
    "modified": 1572891670,
    "terms": [
        "420",
        "Adult",
        "Airline",
        "Ammo"
        ...
    ]
}

POST /terms

Add additional terms to terms dictionary and return updated dictionary

POST /prod/terms HTTP/1.1
Content-Type: application/json
Content-Length: 189

{
    "terms": [
        "Coffee",
        "Theft"
    ]
}
200 OK - Response
{
    "modified": 1572893178,
    "terms": [
        "420",
        "Adult",
        "Airline",
        "Ammo",
        ...
        "Coffee",
        "Theft"
    ]
}

PUT /terms

Replace all terms in dictionary and return updated dictionary

POST /prod/terms HTTP/1.1
Content-Type: application/json
Content-Length: 167

{
    "terms": [
        "Island",
        "Epstein"
    ]
}
200 OK - Response
{
    "modified": 1572893446,
    "terms": [
        "Island",
        "Epstein"
    ]
}

Links

Serverless Framework example for Golang and Lambda

Serverless Examples

About

Lambda based fuzzy matching function with mutable terms dictionary


Languages

Language:Go 95.8%Language:Makefile 4.2%