fork of go-sonic so I can add a version tag
Find a file
2019-03-27 11:33:04 +01:00
cmd/example fix bulk 2019-03-27 11:32:37 +01:00
sonic fix bulk 2019-03-27 11:32:37 +01:00
.gitignore fix git ignore 2019-03-25 20:39:42 +01:00
go.mod first version of go-sonic, missing lot of stuff 2019-03-25 15:58:07 +01:00
readme.md update readme 2019-03-27 11:33:04 +01:00

GoDoc

Go client for the sonic search backend

This package implement all commands to work with sonic. If there is one missing, open an issue ! :)

Sonic: https://github.com/valeriansaliou/sonic

Install

go get github.com/expectedsh/go-sonic

Example

package main

import (
	"fmt"
	"github.com/expectedsh/go-sonic/sonic"
)

func main() {
	ingester, err := sonic.NewIngester("localhost", 1491, "SecretPassword")
	if err != nil {
		panic(err)
	}

	// I will ignore all errors for demonstration purposes

	_ = ingester.BulkPush("movies", "general", []sonic.IngestBulkRecord{
		{"id:6ab56b4kk3", "Star wars"},
		{"id:5hg67f8dg5", "Spider man"},
		{"id:1m2n3b4vf6", "Batman"},
		{"id:68d96h5h9d0", "This is another movie"},
	})

	search, err := sonic.NewSearch("localhost", 1491, "SecretPassword")
	if err != nil {
		panic(err)
	}

	results, _ := search.Query("movies", "general", "man", 10, 0)

	fmt.Println(results)
}