Skip to content

manticoresoftware/manticoresearch-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 Search manticoresearch-go Go
dev dev >= 1.17.0
>= 6.3.6 v2.0.x >= 1.17.0
>= 6.2.12 v1.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

Class Method HTTP request Description
IndexAPI Bulk Post /bulk Bulk index operations
IndexAPI Delete Post /delete Delete a document in an index
IndexAPI Insert Post /insert Create a new document in an index
IndexAPI PartialReplace Post /{index}/_update/{id} Partially replaces a document in an index
IndexAPI Replace Post /replace Replace new document in an index
IndexAPI Update Post /update Update a document in an index
SearchAPI Percolate Post /pq/{index}/search Perform reverse search on a percolate index
SearchAPI Search Post /search Performs a search on an index
UtilsAPI Sql Post /sql Perform 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:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime