Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.
/ appsearch Public archive

Incomplete golang client implementation for Elastic App Search API

License

Notifications You must be signed in to change notification settings

api-haus/appsearch

Repository files navigation

appsearch

AppSearch API Client for GoLang (incomplete).

Documentation

Quickstart

package main

import (
	"context"
	"github.com/yurihq/appsearch"
)

func main() {
	client, _ := appsearch.Open("https://[email protected]")

	// Engine will be created if it doesn't exist and schema will be updated
	client.EnsureEngine(ctx, appsearch.CreateEngineRequest{
		Name:     "civilizations",
		Language: "en",
	}, appsearch.SchemaDefinition{
		"name":        "text",
		"rating":      "number",
		"description": "text",
	})

	client.UpdateDocuments(ctx, "civilizations", []map[string]interface{}{
		{"name": "Babylonian", "rating": 5212.2, "description": "Technological and scientific"},
	})

	search, _ := client.SearchDocuments(ctx, "civilizations", appsearch.Query{
		Query: "science",
	})

	println(search.Results[0])

	/*
	{
	  "_meta": {
	    "score": 1396363.1
	  },
	  "name": {
	    "raw": "Babylonian"
	  },
	  "description": {
	    "raw": "Technological and scientific"
	  },
	  "rating": {
	    "raw": 5212.2
	  },
	  "id": {
	    "raw": "park_everglades"
	  }
	}
	*/
}

Implemented API's

About

Incomplete golang client implementation for Elastic App Search API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages