From 3aec93064db93cac1a4fce27ca66582462a895f3 Mon Sep 17 00:00:00 2001 From: nick Date: Mon, 5 Feb 2024 22:01:04 +0700 Subject: [PATCH] Updated documentation --- README.md | 73 ++++++++++++++++++++++++++++++++++++----------- docs/SearchAPI.md | 57 ++++++++++++++++++------------------ 2 files changed, 86 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 64d8d9c..9288a7f 100644 --- a/README.md +++ b/README.md @@ -2,34 +2,67 @@ С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 -## Overview -This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. -- API version: 3.3.1 -- Package version: 1.0.0 -- Build package: org.openapitools.codegen.languages.GoClientCodegen -For more information, please visit [https://manticoresearch.com/contact-us/](https://manticoresearch.com/contact-us/) +## Requiments + +| Manticore Search | manticoresearch-go | Go | +| ----------------- | ---------------------------- | ------------- | +| >= 6.2.12 | v1.0.0 | >= 17.0 | ## Installation -Install the following dependencies: +```shell + +go get github.com/manticoresoftware/manticoresearch-go -```sh -go get github.com/stretchr/testify/assert -go get golang.org/x/net/context ``` -Put the package under your project folder and add the following in import: +## Getting Started ```go -import openapi "github.com/manticoresoftware/manticoresearch-go" -``` -To use a proxy, set the environment variable `HTTP_PROXY`: +package main + +import ( + "context" + "fmt" + "os" + "strings" + openapiclient "github.com/manticoresoftware/manticoresearch-go" +) + +func main() { + + // Initialize ApiClient + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + + // Add documents to an index + docs := []string { + "{\"insert\": {\"index\" : \"test\", \"id\" : 1, \"doc\" : {\"title\" : \"Title 1\"}}}", + "{\"insert\": {\"index\" : \"test\", \"id\" : 2, \"doc\" : {\"title\" : \"Title 2\"}}}" + } + apiClient.IndexAPI.Bulk(context.Background()).Body(strings.Join(docs[:], "\n")).Execute() + + // response from `Search`: SearchRequest + searchRequest := *openapiclient.NewSearchRequest("test") + + // Perform a search + query := map[string]interface{} {"query_string": "Title"} + searchRequest.SetQuery(query) + resp, r, err := apiClient.SearchAPI.Search(context.Background()).SearchRequest(searchRequest).Execute() + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SearchAPI.Search``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `Search`: SearchResponse + fmt.Fprintf(os.Stdout, "Response from `SearchAPI.Search`: %v\n", resp) +} + -```go -os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port") ``` ## Configuration of Server URL @@ -73,6 +106,14 @@ ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVari }) ``` +### Using proxy + +To use a proxy, set the environment variable `HTTP_PROXY`: + +```go +os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port") +``` + ## Documentation for API Endpoints All URIs are relative to *http://127.0.0.1:9308* diff --git a/docs/SearchAPI.md b/docs/SearchAPI.md index b71d531..b1fdd96 100755 --- a/docs/SearchAPI.md +++ b/docs/SearchAPI.md @@ -4,16 +4,15 @@ All URIs are relative to *http://127.0.0.1:9308* Method | HTTP request | Description ------------- | ------------- | ------------- -[**Percolate**](SearchAPI.md#Percolate) | **Post** /pq/{index}/search | Perform reverse search on a percolate index [**Search**](SearchAPI.md#Search) | **Post** /search | Performs a search on an index +[**Percolate**](SearchAPI.md#Percolate) | **Post** /pq/{index}/search | Perform reverse search on a percolate index +## Search -## Percolate - -> SearchResponse Percolate(ctx, index).PercolateRequest(percolateRequest).Execute() +> SearchResponse Search(ctx).SearchRequest(searchRequest).Execute() -Perform reverse search on a percolate index +Performs a search on an index @@ -30,38 +29,34 @@ import ( ) func main() { - index := "index_example" // string | Name of the percolate index - percolateRequest := *openapiclient.NewPercolateRequest(*openapiclient.NewPercolateRequestQuery(map[string]interface{}(123))) // PercolateRequest | + searchRequest := *openapiclient.NewSearchRequest("test") // SearchRequest | + query := map[string]interface{} {"query_string": "Title"} + searchRequest.SetQuery(query); configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) - resp, r, err := apiClient.SearchAPI.Percolate(context.Background(), index).PercolateRequest(percolateRequest).Execute() + resp, r, err := apiClient.SearchAPI.Search(context.Background()).SearchRequest(searchRequest).Execute() if err != nil { - fmt.Fprintf(os.Stderr, "Error when calling `SearchAPI.Percolate``: %v\n", err) + fmt.Fprintf(os.Stderr, "Error when calling `SearchAPI.Search``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } - // response from `Percolate`: SearchResponse - fmt.Fprintf(os.Stdout, "Response from `SearchAPI.Percolate`: %v\n", resp) + // response from `Search`: SearchResponse + fmt.Fprintf(os.Stdout, "Response from `SearchAPI.Search`: %v\n", resp) } ``` ### Path Parameters -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- -**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. -**index** | **string** | Name of the percolate index | ### Other Parameters -Other parameters are passed through a pointer to a apiPercolateRequest struct via the builder pattern +Other parameters are passed through a pointer to a apiSearchRequest struct via the builder pattern Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - - **percolateRequest** | [**PercolateRequest**](PercolateRequest.md) | | + **searchRequest** | [**SearchRequest**](SearchRequest.md) | | ### Return type @@ -81,11 +76,11 @@ No authorization required [[Back to README]](../README.md) -## Search +## Percolate -> SearchResponse Search(ctx).SearchRequest(searchRequest).Execute() +> SearchResponse Percolate(ctx, index).PercolateRequest(percolateRequest).Execute() -Performs a search on an index +Perform reverse search on a percolate index @@ -102,32 +97,38 @@ import ( ) func main() { - searchRequest := *openapiclient.NewSearchRequest("test") // SearchRequest | + index := "index_example" // string | Name of the percolate index + percolateRequest := *openapiclient.NewPercolateRequest(*openapiclient.NewPercolateRequestQuery(map[string]interface{}(123))) // PercolateRequest | configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) - resp, r, err := apiClient.SearchAPI.Search(context.Background()).SearchRequest(searchRequest).Execute() + resp, r, err := apiClient.SearchAPI.Percolate(context.Background(), index).PercolateRequest(percolateRequest).Execute() if err != nil { - fmt.Fprintf(os.Stderr, "Error when calling `SearchAPI.Search``: %v\n", err) + fmt.Fprintf(os.Stderr, "Error when calling `SearchAPI.Percolate``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } - // response from `Search`: SearchResponse - fmt.Fprintf(os.Stdout, "Response from `SearchAPI.Search`: %v\n", resp) + // response from `Percolate`: SearchResponse + fmt.Fprintf(os.Stdout, "Response from `SearchAPI.Percolate`: %v\n", resp) } ``` ### Path Parameters +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**index** | **string** | Name of the percolate index | ### Other Parameters -Other parameters are passed through a pointer to a apiSearchRequest struct via the builder pattern +Other parameters are passed through a pointer to a apiPercolateRequest struct via the builder pattern Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **searchRequest** | [**SearchRequest**](SearchRequest.md) | | + + **percolateRequest** | [**PercolateRequest**](PercolateRequest.md) | | ### Return type