Terminal Terminal | Web Web
Home  //  Play

Go client for Manticore Search

Difficulty: Beginner
Estimated Time: 5 minutes

Manticoresearch - Introduction in GO-SDK

In this tutorial we will study how to use Go-SDK, the official Go client for Manticore Search.

Go client for Manticore Search

Step 1 of 3

Installation

First we make sure there's a running Manticore instance on the machine

searchd --status

Now we can instal Go-SDK with the following command:

go get github.com/manticoresoftware/go-sdk/manticore

Basic usage

Lets' take a look at this simple Go script:

cat manticore.go

The script creates a new Manticore client, executes simple INSERT requests to the testrt table and then makes a query for the added content.

Let's run it:

go run manticore.go

As we see, new docs were succesfully added to the table and two docs containing more or another words were found by the query.

A couple more examples

With Go-SDK you can easily filter your query results by table attributes

cat manticore2.go

This script creates a new Manticore client, executes simple INSERT requests to the testrt table and then makes two queries searching for content word. The first query retrieves all docs as all docs in the table now contain this word. The second query uses the filter we've created and retrieves only the docs that contain content word and have attribute gid equal to 10. In our case, there's only one doc under these conditions, with id=10

go run manticore2.go

You can also use an SQL-like expression to do your filtering.

cat manticore3.go

Here we use 'gid > 10 AND gid < 20' expression to filter our query result. Like in the previous example the first query retrieves all the docs from the table and the second one retrieves only the docs with gid=15

go run manticore3.go