Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sajari/sajari-sdk-go
Search.io APIs Go Client Library
https://github.com/sajari/sajari-sdk-go
go golang sajari search
Last synced: 7 days ago
JSON representation
Search.io APIs Go Client Library
- Host: GitHub
- URL: https://github.com/sajari/sajari-sdk-go
- Owner: sajari
- License: mit
- Created: 2017-02-27T00:22:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-01T01:19:46.000Z (over 5 years ago)
- Last Synced: 2024-06-21T00:08:17.707Z (5 months ago)
- Topics: go, golang, sajari, search
- Language: Go
- Homepage: https://godoc.org/github.com/sajari/sajari-sdk-go
- Size: 33.2 KB
- Stars: 4
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sajari APIs Go Client · [![Build Status](https://travis-ci.org/sajari/sajari-sdk-go.svg?branch=master)](https://travis-ci.org/sajari/sajari-sdk-go)
This repository provides functionality for interacting with Sajari APIs.
# Installation
If you haven't setup Go before, you need to first set a `GOPATH` (see [https://golang.org/doc/code.html#GOPATH](https://golang.org/doc/code.html#GOPATH)).
To fetch and build the code:
$ go get code.sajari.com/sajari-sdk-go/...
This will also build the command line tools (in particular `query`, `csv-importer`, `schema` and `pipeline` which can be used to interaction with Sajari collections) into `$GOPATH/bin` (assumed to be in your `PATH` already).
# Getting Started
```go
package mainimport (
"log""golang.org/x/net/context"
"code.sajari.com/sajari-sdk-go"
)func main() {
creds := sajari.KeyCredentials("", "")
client, err := sajari.New("", "", sajari.WithCredentials(creds))
if err != nil {
log.Fatalf("error creating client: %v", err)
}
defer client.Close()// Initialise the "website" pipeline. Ideal starting point for querying
// website collections.
pipeline := client.Pipeline("website")// Setup parameters for the search.
values := map[string]string{
"q": "search terms",
"resultsPerPage": "10",
}// Setup tracking for the search results.
t := sajari.Tracking{
Type: sajari.TrackingClick, // Enable click tracking.
Field: "url", // Use the url field for identifying records.
}// Perform the search.
resp, _, err := pipeline.Search(context.Background(), values, t)
if err != nil {
log.Fatalf("error performing search: %v", err)
}for _, r := range resp.Results {
log.Printf("Values: %v", r.Values)
log.Println("Tokens: %v", r.Tokens)
}
}
```