Skip to content

Commit

Permalink
Updated Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nick committed Oct 29, 2024
1 parent 7423e70 commit 97419cf
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

❗ 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 |
Expand All @@ -19,44 +18,51 @@

```shell

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

```

## Getting Started

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

```go

package main

import (
"context"
"fmt:
Manticoresearch "github.com/manticoresoftware/manticoresearch-go"
)
# Create 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

res, _, _ := apiClient.SearchAPI.Search(context.Background()).SearchRequest(*searchRequest).Execute()

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
Expand Down

0 comments on commit 97419cf

Please # to comment.