Home

Awesome

Manticorer Go client

Сlient for Manticore Search.

❗ WARNING: this is a development version of the client. The latest release's readme is https://github.com/manticoresoftware/manticoresearch-go/tree/v1.0.0

Requiments

Manticore Searchmanticoresearch-goGo
devdev>= 1.17.0
>= 6.3.6v2.0.x>= 1.17.0
>= 6.2.12v1.0.0>= 1.17.0

Installation


go get github.com/manticoresoftware/manticoresearch-go@dev

Getting Started

go mod init main go get github.com/manticoresoftware/manticoresearch-go@dev


package main

import (
	"context"
	"fmt:
	Manticoresearch "github.com/manticoresoftware/manticoresearch-go"
)

func main() {

	# Create an instance of API client
	configuration := Manticoresearch.NewConfiguration()
	configuration.Servers[0].URL = "http://localhost:9308"
	apiClient := Manticoresearch.NewAPIClient(configuration)
	
	# Perform insert and search operations
	tableName := "products"
	indexDoc := map[string]interface{} {"title": "Crossbody Bag with Tassel"}
	indexReq := Manticoresearch.NewInsertDocumentRequest(tableName, indexDoc)
	indexReq.SetId(1)
	
	apiClient.IndexAPI.Insert(context.Background()).InsertDocumentRequest(*indexReq).Execute();
	
	searchRequest := Manticoresearch.NewSearchRequest(tableName)
	searchQuery := Manticoresearch.NewSearchQuery()
	searchQuery.QueryString = "@title Bag"
	searchRequest.Query = searchQuery
	queryHighlight := Manticoresearch.NewHighlight()
	queryHighlight.Fields =  map[string]interface{} {"title": map[string]interface{} {}}
	searchRequest.Highlight = queryHighlight      
	
	_, httpRes, _ := apiClient.SearchAPI.Search(context.Background()).SearchRequest(*searchRequest).Execute()
	fmt.Printf("%+v\n\n", httpRes)
}

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value openapi.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value openapi.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

Using proxy

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

More details on the use of HTTP_PROXY can be found here

Documentation for API Endpoints

All URIs are relative to http://127.0.0.1:9308

ClassMethodHTTP requestDescription
IndexAPIBulkPost /bulkBulk index operations
IndexAPIDeletePost /deleteDelete a document in an index
IndexAPIInsertPost /insertCreate a new document in an index
IndexAPIPartialReplacePost /{index}/_update/{id}Partially replaces a document in an index
IndexAPIReplacePost /replaceReplace new document in an index
IndexAPIUpdatePost /updateUpdate a document in an index
SearchAPIPercolatePost /pq/{index}/searchPerform reverse search on a percolate index
SearchAPISearchPost /searchPerforms a search on an index
UtilsAPISqlPost /sqlPerform SQL requests

Documentation For Models

Documentation For Authorization

Endpoints do not require authorization.

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it: