meilisearch

package module
v1.12.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2020 License: MIT Imports: 16 Imported by: 2

README ΒΆ

MeiliSearch-Go

MeiliSearch Go

MeiliSearch | Documentation | Website | Blog | Twitter | FAQ

GitHub Workflow Status Test License Slack

⚑ The MeiliSearch API client written for Golang

MeiliSearch Go is the MeiliSearch API client for Go developers. MeiliSearch is a powerful, fast, open-source, easy to use and deploy search engine. Both searching and indexing are highly customizable. Features such as typo-tolerance, filters, facets and synonyms are provided out-of-the-box.

Table of Contents

πŸ“– Documentation

See our Documentation or our API References.

πŸ”§ Installation

With go get in command line:

$ go get github.com/meilisearch/meilisearch-go

Run MeiliSearch

There are many easy ways to download and run a MeiliSearch instance.

For example, if you use Docker:

$ docker pull getmeili/meilisearch:latest # Fetch the latest version of MeiliSearch image from Docker Hub
$ docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey

NB: you can also download MeiliSearch from Homebrew or APT.

πŸš€ Getting Started

Add documents
package main

import (
    "fmt"
    "os"

    "github.com/meilisearch/meilisearch-go"
)

func main() {
    var client = meilisearch.NewClient(meilisearch.Config{
        Host: "http://127.0.0.1:7700",
        APIKey: "masterKey",
    })

    // Create an index if your index does not already exist
    _, err := client.Indexes().Create(meilisearch.CreateIndexRequest{
        UID: "books",
    })
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }

    documents := []map[string]interface{}{
        {"book_id": 123,  "title": "Pride and Prejudice"},
        {"book_id": 456,  "title": "Le Petit Prince"},
        {"book_id": 1,    "title": "Alice In Wonderland"},
        {"book_id": 1344, "title": "The Hobbit"},
        {"book_id": 4,    "title": "Harry Potter and the Half-Blood Prince"},
        {"book_id": 42,   "title": "The Hitchhiker's Guide to the Galaxy"},
    }

    updateRes, err := client.Documents("books").AddOrUpdate(documents) // => { "updateId": 0 }
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }

    fmt.Println(updateRes.UpdateID)
}

With the updateId, you can check the status (enqueued, processed or failed) of your documents addition using the update endpoint.

package main

import (
    "fmt"
    "os"

    "github.com/meilisearch/meilisearch-go"
)

func main() {
    // MeiliSearch is typo-tolerant:
    searchRes, err := client.Search("books").Search(meilisearch.SearchRequest{
        Query: "harry pottre",
        Limit: 10,
    })
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }

    fmt.Println(searchRes.Hits)
}

JSON output:

{
  "hits": [{
    "book_id": 4,
    "title": "Harry Potter and the Half-Blood Prince"
  }],
  "offset": 0,
  "limit": 10,
  "processingTimeMs": 1,
  "query": "harry pottre"
}

All the supported options are described in the search parameters section of the documentation.

func main() {
    resp, err := client.Search(indexUID).Search(meilisearch.SearchRequest{
        Query: "prince",
        AttributesToHighlight: []string{"*"},
        Filters: "book_id > 10"
    })
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }

    fmt.Println(searchRes.Hits)
}

JSON output:

{
    "hits": [
        {
            "book_id": 456,
            "title": "Le Petit Prince",
            "_formatted": {
                "book_id": 456,
                "title": "Le Petit <em>Prince</em>"
            }
        }
    ],
    "offset": 0,
    "limit": 1,
    "processingTimeMs": 0,
    "query": "prince"
}

πŸ€– Compatibility with MeiliSearch

This package only guarantees the compatibility with the version v0.15.0 of MeiliSearch.

πŸ’‘ Learn More

The following sections may interest you:

βš™οΈ Development Workflow and Contributing

Any new contribution is more than welcome in this project!

If you want to know more about the development workflow or want to contribute, please visit our contributing guidelines for detailed instructions!


MeiliSearch provides and maintains many SDKs and Integration tools like this one. We want to provide everyone with an amazing search experience for any kind of project. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the integration-guides repository.

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

This section is empty.

Types ΒΆ

type APIDocuments ΒΆ

type APIDocuments interface {

	// Get one document using its unique identifier.
	// documentPtr should be a pointer.
	Get(identifier string, documentPtr json.Unmarshaler) error

	// Delete one document based on its unique identifier.
	Delete(identifier string) (*AsyncUpdateID, error)

	// Delete a selection of documents based on array of identifiers.
	Deletes(identifier StrsArr) (*AsyncUpdateID, error)

	// List the documents in an unordered way.
	List(request ListDocumentsRequest, documentsPtr json.Unmarshaler) error

	// AddOrReplace a list of documents, replace them if they already exist based on their unique identifiers.
	AddOrReplace(documentsPtr json.Marshaler) (*AsyncUpdateID, error)

	// AddOrReplaceWithPrimaryKey do the same as AddOrReplace but will specify during the update to primaryKey to use for indexing
	AddOrReplaceWithPrimaryKey(documentsPtr json.Marshaler, primaryKey string) (resp *AsyncUpdateID, err error)

	// AddOrUpdate a list of documents, update them if they already exist based on their unique identifiers.
	AddOrUpdate(documentsPtr json.Marshaler) (*AsyncUpdateID, error)

	// AddOrUpdateWithPrimaryKey do the same as AddOrUpdate but will specify during the update to primaryKey to use for indexing
	AddOrUpdateWithPrimaryKey(documentsPtr json.Marshaler, primaryKey string) (resp *AsyncUpdateID, err error)

	// DeleteAllDocuments in the specified index.
	DeleteAllDocuments() (*AsyncUpdateID, error)

	APIWithIndexID
}

APIDocuments are objects composed of fields containing any data.

Documentation: https://docs.meilisearch.com/references/documents.html

type APIHealth ΒΆ

type APIHealth interface {

	// Get health of MeiliSearch server.
	Get() error

	// Update health of MeiliSearch server.
	Update(health bool) error
}

APIHealth handle health of a MeiliSearch server.

Documentation: https://docs.meilisearch.com/references/health.html

type APIIndexes ΒΆ

type APIIndexes interface {

	// Get the index relative information.
	Get(uid string) (*Index, error)

	// List all indexes.
	List() (Indexes, error)

	// Create an index.
	// If no UID is specified in the request a randomly generated UID will be returned.
	// It's associated to the new index. This UID will be essential to make all request over the created index.
	// You can define your primary key during the index creation
	Create(request CreateIndexRequest) (*CreateIndexResponse, error)

	// Update an index name.
	UpdateName(uid string, name string) (*Index, error)

	// Update an index primary key.
	UpdatePrimaryKey(uid string, primaryKey string) (*Index, error)

	// Delete an index.
	Delete(uid string) (bool, error)
}

APIIndexes index is an entity, like a table in SQL, with a specific schema definition. It gathers a collection of documents with the structure defined by the schema. An index is defined by an unique identifier uid that is generated by MeiliSearch (if none is given) on index creation. It also has a name to help you track your different indexes.

Documentation: https://docs.meilisearch.com/references/indexes.html

type APIKeys ΒΆ

type APIKeys interface {

	// Get all keys.
	Get() (*Keys, error)
}

APIKeys To communicate with MeiliSearch's RESTfull API most of the routes require an API key.

Documentation: https://docs.meilisearch.com/references/keys.html

type APISearch ΒΆ

type APISearch interface {

	// Search for documents matching a specific query in the given index.
	Search(params SearchRequest) (*SearchResponse, error)

	APIWithIndexID
}

APISearch search through documents list in an index.

Documentation: https://docs.meilisearch.com/references/search.html

type APISettings ΒΆ

type APISettings interface {
	GetAll() (*Settings, error)

	UpdateAll(request Settings) (*AsyncUpdateID, error)

	ResetAll() (*AsyncUpdateID, error)

	GetRankingRules() (*StrsArr, error)

	UpdateRankingRules(arr StrsArr) (*AsyncUpdateID, error)

	ResetRankingRules() (*AsyncUpdateID, error)

	GetDistinctAttribute() (*Str, error)

	UpdateDistinctAttribute(Str) (*AsyncUpdateID, error)

	ResetDistinctAttribute() (*AsyncUpdateID, error)

	GetSearchableAttributes() (*StrsArr, error)

	UpdateSearchableAttributes(StrsArr) (*AsyncUpdateID, error)

	ResetSearchableAttributes() (*AsyncUpdateID, error)

	GetDisplayedAttributes() (*StrsArr, error)

	UpdateDisplayedAttributes(StrsArr) (*AsyncUpdateID, error)

	ResetDisplayedAttributes() (*AsyncUpdateID, error)

	GetStopWords() (*StrsArr, error)

	UpdateStopWords(StrsArr) (*AsyncUpdateID, error)

	ResetStopWords() (*AsyncUpdateID, error)

	GetSynonyms() (*Synonyms, error)

	UpdateSynonyms(synonyms Synonyms) (*AsyncUpdateID, error)

	ResetSynonyms() (*AsyncUpdateID, error)

	GetAttributesForFaceting() (*StrsArr, error)

	UpdateAttributesForFaceting(StrsArr) (*AsyncUpdateID, error)

	ResetAttributesForFaceting() (*AsyncUpdateID, error)
}

APISettings allow to configure the MeiliSearch indexing & search behaviour.

Documentation: https://docs.meilisearch.com/references/settings.html

type APIStats ΒΆ

type APIStats interface {

	// Get stats of an index.
	Get(indexUID string) (*StatsIndex, error)

	GetAll() (*Stats, error)
}

APIStats retrieve statistic over all indexes or a specific index id.

Documentation: https://docs.meilisearch.com/references/stats.html

type APIUpdates ΒΆ

type APIUpdates interface {

	// Get the status of an update in a given index.
	Get(id int64) (*Update, error)

	// Get the status of all updates in a given index.
	List() (Updates, error)

	APIWithIndexID
}

APIUpdates MeiliSearch is an asynchronous API. It means that the API does not behave as you would typically expect when handling the request's responses.

Some actions are put in a queue and will be executed in turn (asynchronously). In this case, the server response contains the identifier to track the execution of the action.

This API permit to get the state of an update id.

Documentation: https://docs.meilisearch.com/references/updates.html

type APIVersion ΒΆ

type APIVersion interface {

	// Get version of MeiliSearch.
	Get() (*Version, error)
}

APIVersion retrieve the version of MeiliSearch.

Documentation: https://docs.meilisearch.com/references/version.html

type APIWithIndexID ΒΆ

type APIWithIndexID interface {
	IndexID() string
	Client() ClientInterface
}

APIWithIndexID is used to await an async update id response. Each apis that use an index internally implement this interface except APIUpdates.

type AsyncUpdateID ΒΆ

type AsyncUpdateID struct {
	UpdateID int64 `json:"updateID"`
}

AsyncUpdateID is returned for asynchronous method

Documentation: https://docs.meilisearch.com/guides/advanced_guides/asynchronous_updates.html

func (AsyncUpdateID) MarshalEasyJSON ΒΆ

func (v AsyncUpdateID) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (AsyncUpdateID) MarshalJSON ΒΆ

func (v AsyncUpdateID) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*AsyncUpdateID) UnmarshalEasyJSON ΒΆ

func (v *AsyncUpdateID) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*AsyncUpdateID) UnmarshalJSON ΒΆ

func (v *AsyncUpdateID) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ClientInterface ΒΆ

type ClientInterface interface {
	Indexes() APIIndexes
	Version() APIVersion
	Documents(indexID string) APIDocuments
	Search(indexID string) APISearch
	Updates(indexID string) APIUpdates
	Settings(indexID string) APISettings
	Keys() APIKeys
	Stats() APIStats
	Health() APIHealth
}

func NewFastHttpCustomClient ΒΆ

func NewFastHttpCustomClient(config Config, client *fasthttp.Client) ClientInterface

type Config ΒΆ

type Config struct {

	// Host is the host of your meilisearch database
	// Example: 'http://localhost:7700'
	Host string

	// APIKey is optional
	APIKey string
}

Config configure the Client

type CreateIndexRequest ΒΆ

type CreateIndexRequest struct {
	Name       string `json:"name,omitempty"`
	UID        string `json:"uid,omitempty"`
	PrimaryKey string `json:"primaryKey,omitempty"`
}

CreateIndexRequest is the request body for create index method

func (CreateIndexRequest) MarshalEasyJSON ΒΆ

func (v CreateIndexRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (CreateIndexRequest) MarshalJSON ΒΆ

func (v CreateIndexRequest) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*CreateIndexRequest) UnmarshalEasyJSON ΒΆ

func (v *CreateIndexRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*CreateIndexRequest) UnmarshalJSON ΒΆ

func (v *CreateIndexRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type CreateIndexResponse ΒΆ

type CreateIndexResponse struct {
	Name       string    `json:"name"`
	UID        string    `json:"uid"`
	UpdateID   int64     `json:"updateID,omitempty"`
	CreatedAt  time.Time `json:"createdAt"`
	UpdatedAt  time.Time `json:"updatedAt"`
	PrimaryKey string    `json:"primaryKey,omitempty"`
}

CreateIndexResponse is the response body for create index method

func (CreateIndexResponse) MarshalEasyJSON ΒΆ

func (v CreateIndexResponse) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (CreateIndexResponse) MarshalJSON ΒΆ

func (v CreateIndexResponse) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*CreateIndexResponse) UnmarshalEasyJSON ΒΆ

func (v *CreateIndexResponse) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*CreateIndexResponse) UnmarshalJSON ΒΆ

func (v *CreateIndexResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ErrCode ΒΆ

type ErrCode int

ErrCode are all possible errors found during requests

const (
	// ErrCodeUnknown default error code, undefined
	ErrCodeUnknown ErrCode = 0
	// ErrCodeMarshalRequest impossible to serialize request body
	ErrCodeMarshalRequest ErrCode = iota + 1
	// ErrCodeRequestCreation impossible create a request
	ErrCodeRequestCreation
	// ErrCodeRequestExecution impossible execute a request
	ErrCodeRequestExecution
	// ErrCodeResponseStatusCode the response status code is not conform
	ErrCodeResponseStatusCode
	// ErrCodeResponseReadBody impossible to read the response body
	ErrCodeResponseReadBody
	// ErrCodeResponseUnmarshalBody impossible deserialize the response body
	ErrCodeResponseUnmarshalBody
	// ErrCodeURLParsing impossible to parse url parameters
	ErrCodeURLParsing
)

type Error ΒΆ

type Error struct {
	// Endpoint is the path of the request (host is not in)
	Endpoint string

	// Method is the HTTP verb of the request
	Method string

	// Function name used
	Function string

	// APIName is which part/module of the api
	APIName string

	// RequestToString is the raw request into string ('empty request' if not present)
	RequestToString string

	// RequestToString is the raw request into string ('empty response' if not present)
	ResponseToString string

	// MeilisearchMessage is the raw request into string ('empty meilisearch message' if not present)
	MeilisearchMessage string

	// StatusCode of the request
	StatusCode int

	// StatusCode expected by the endpoint to be considered as a success
	StatusCodeExpected []int

	// OriginError is the origin error that produce the current Error. It can be nil in case of a bad status code.
	OriginError error

	// ErrCode is the internal error code that represent the different step when executing a request that can produce
	// an error.
	ErrCode ErrCode
	// contains filtered or unexported fields
}

Error is the internal error structure that all exposed method use. So ALL errors returned by this library can be cast to this struct (as a pointer)

func (Error) Error ΒΆ

func (e Error) Error() string

Error return a well human formatted message.

func (*Error) ErrorBody ΒΆ

func (e *Error) ErrorBody(body []byte)

ErrorBody add a body to an error

func (*Error) WithErrCode ΒΆ

func (e *Error) WithErrCode(err ErrCode, errs ...error) *Error

WithErrCode add an error code to an error

func (*Error) WithMessage ΒΆ

func (e *Error) WithMessage(str string, errs ...error) *Error

WithMessage add a message to an error

type FastHttpClient ΒΆ

type FastHttpClient struct {
	// contains filtered or unexported fields
}

Client is a structure that give you the power for interacting with an high-level api with meilisearch.

func (FastHttpClient) DefaultWaitForPendingUpdate ΒΆ

func (c FastHttpClient) DefaultWaitForPendingUpdate(indexUID string, updateID *AsyncUpdateID) (UpdateStatus, error)

func (*FastHttpClient) Documents ΒΆ

func (c *FastHttpClient) Documents(indexID string) APIDocuments

func (*FastHttpClient) Health ΒΆ

func (c *FastHttpClient) Health() APIHealth

func (*FastHttpClient) Indexes ΒΆ

func (c *FastHttpClient) Indexes() APIIndexes

func (*FastHttpClient) Keys ΒΆ

func (c *FastHttpClient) Keys() APIKeys

func (*FastHttpClient) Search ΒΆ

func (c *FastHttpClient) Search(indexID string) APISearch

func (*FastHttpClient) Settings ΒΆ

func (c *FastHttpClient) Settings(indexID string) APISettings

func (*FastHttpClient) Stats ΒΆ

func (c *FastHttpClient) Stats() APIStats

func (*FastHttpClient) Updates ΒΆ

func (c *FastHttpClient) Updates(indexID string) APIUpdates

func (*FastHttpClient) Version ΒΆ

func (c *FastHttpClient) Version() APIVersion

func (FastHttpClient) WaitForPendingUpdate ΒΆ

func (c FastHttpClient) WaitForPendingUpdate(
	ctx context.Context,
	interval time.Duration,
	indexID string,
	updateID *AsyncUpdateID) (UpdateStatus, error)

WaitForPendingUpdate waits for the end of an update. The function will check by regular interval provided in parameter interval the UpdateStatus. If it is not UpdateStatusEnqueued or the ctx cancelled we return the UpdateStatus.

type Health ΒΆ

type Health struct {
	Health bool
}

func (Health) MarshalEasyJSON ΒΆ

func (v Health) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Health) MarshalJSON ΒΆ

func (v Health) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Health) UnmarshalEasyJSON ΒΆ

func (v *Health) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Health) UnmarshalJSON ΒΆ

func (v *Health) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Index ΒΆ

type Index struct {
	Name       string    `json:"name"`
	UID        string    `json:"uid"`
	CreatedAt  time.Time `json:"createdAt"`
	UpdatedAt  time.Time `json:"updatedAt"`
	PrimaryKey string    `json:"primaryKey,omitempty"`
}

Index is the type that represent an index in MeiliSearch

func (Index) MarshalEasyJSON ΒΆ

func (v Index) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Index) MarshalJSON ΒΆ

func (v Index) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Index) UnmarshalEasyJSON ΒΆ

func (v *Index) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Index) UnmarshalJSON ΒΆ

func (v *Index) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Indexes ΒΆ

type Indexes []Index

func (Indexes) MarshalJSON ΒΆ

func (i Indexes) MarshalJSON() ([]byte, error)

func (*Indexes) UnmarshalJSON ΒΆ

func (i *Indexes) UnmarshalJSON(data []byte) error

type Keys ΒΆ

type Keys struct {
	Public  string `json:"public,omitempty"`
	Private string `json:"private,omitempty"`
}

Keys allow the user to connect to the MeiliSearch instance

Documentation: https://docs.meilisearch.com/guides/advanced_guides/asynchronous_updates.html

func (Keys) MarshalEasyJSON ΒΆ

func (v Keys) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Keys) MarshalJSON ΒΆ

func (v Keys) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Keys) UnmarshalEasyJSON ΒΆ

func (v *Keys) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Keys) UnmarshalJSON ΒΆ

func (v *Keys) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ListDocumentsRequest ΒΆ

type ListDocumentsRequest struct {
	Offset               int64    `json:"offset,omitempty"`
	Limit                int64    `json:"limit,omitempty"`
	AttributesToRetrieve []string `json:"attributesToRetrieve,omitempty"`
}

ListDocumentsRequest is the request body for list documents method

func (ListDocumentsRequest) MarshalEasyJSON ΒΆ

func (v ListDocumentsRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ListDocumentsRequest) MarshalJSON ΒΆ

func (v ListDocumentsRequest) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ListDocumentsRequest) UnmarshalEasyJSON ΒΆ

func (v *ListDocumentsRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ListDocumentsRequest) UnmarshalJSON ΒΆ

func (v *ListDocumentsRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Name ΒΆ

type Name struct {
	Name string
}

func (Name) MarshalEasyJSON ΒΆ

func (v Name) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Name) MarshalJSON ΒΆ

func (v Name) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Name) UnmarshalEasyJSON ΒΆ

func (v *Name) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Name) UnmarshalJSON ΒΆ

func (v *Name) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type PrimaryKey ΒΆ

type PrimaryKey struct {
	PrimaryKey string
}

func (PrimaryKey) MarshalEasyJSON ΒΆ

func (v PrimaryKey) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (PrimaryKey) MarshalJSON ΒΆ

func (v PrimaryKey) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*PrimaryKey) UnmarshalEasyJSON ΒΆ

func (v *PrimaryKey) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*PrimaryKey) UnmarshalJSON ΒΆ

func (v *PrimaryKey) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Query ΒΆ

type Query struct {
	Query                 string `json:"q"`
	Offset                int64
	Limit                 int64
	AttributesToRetrieve  []string
	AttributesToCrop      []string
	CropLength            int64
	AttributesToHighlight []string
	Filters               string
	Matches               bool
	FacetsDistribution    []string
	FacetFilters          interface{}
	PlaceholderSearch     bool
}

func (Query) MarshalEasyJSON ΒΆ

func (v Query) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Query) MarshalJSON ΒΆ

func (v Query) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Query) UnmarshalEasyJSON ΒΆ

func (v *Query) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Query) UnmarshalJSON ΒΆ

func (v *Query) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type RawType ΒΆ

type RawType []byte

func (RawType) MarshalJSON ΒΆ

func (b RawType) MarshalJSON() ([]byte, error)

func (*RawType) UnmarshalJSON ΒΆ

func (b *RawType) UnmarshalJSON(data []byte) error

type Response ΒΆ

type Response interface {
	UnmarshalJSON(data []byte) error
	MarshalJSON() ([]byte, error)
}

type SearchRequest ΒΆ

type SearchRequest struct {
	Query                 string
	Offset                int64
	Limit                 int64
	AttributesToRetrieve  []string
	AttributesToCrop      []string
	CropLength            int64
	AttributesToHighlight []string
	Filters               string
	Matches               bool
	FacetsDistribution    []string
	FacetFilters          interface{}
	PlaceholderSearch     bool
}

SearchRequest is the request url param needed for a search query. This struct will be converted to url param before sent.

Documentation: https://docs.meilisearch.com/guides/advanced_guides/search_parameters.html

func (SearchRequest) MarshalEasyJSON ΒΆ

func (v SearchRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (SearchRequest) MarshalJSON ΒΆ

func (v SearchRequest) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*SearchRequest) UnmarshalEasyJSON ΒΆ

func (v *SearchRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*SearchRequest) UnmarshalJSON ΒΆ

func (v *SearchRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type SearchResponse ΒΆ

type SearchResponse struct {
	Hits                  []interface{} `json:"hits"`
	NbHits                int64         `json:"nbHits"`
	Offset                int64         `json:"offset"`
	Limit                 int64         `json:"limit"`
	ProcessingTimeMs      int64         `json:"processingTimeMs"`
	Query                 string        `json:"query"`
	FacetsDistribution    interface{}   `json:"facetsDistribution,omitempty"`
	ExhaustiveFacetsCount interface{}   `json:"exhaustiveFacetsCount,omitempty"`
}

SearchResponse is the response body for search method

func (SearchResponse) MarshalEasyJSON ΒΆ

func (v SearchResponse) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (SearchResponse) MarshalJSON ΒΆ

func (v SearchResponse) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*SearchResponse) UnmarshalEasyJSON ΒΆ

func (v *SearchResponse) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*SearchResponse) UnmarshalJSON ΒΆ

func (v *SearchResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Settings ΒΆ

type Settings struct {
	RankingRules          []string            `json:"rankingRules,omitempty"`
	DistinctAttribute     *string             `json:"distinctAttribute,omitempty"`
	SearchableAttributes  []string            `json:"searchableAttributes,omitempty"`
	DisplayedAttributes   []string            `json:"displayedAttributes,omitempty"`
	StopWords             []string            `json:"stopWords,omitempty"`
	Synonyms              map[string][]string `json:"synonyms,omitempty"`
	AttributesForFaceting []string            `json:"attributesForFaceting,omitempty"`
}

Settings is the type that represents the settings in MeiliSearch

func (Settings) MarshalEasyJSON ΒΆ

func (v Settings) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Settings) MarshalJSON ΒΆ

func (v Settings) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Settings) UnmarshalEasyJSON ΒΆ

func (v *Settings) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Settings) UnmarshalJSON ΒΆ

func (v *Settings) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Stats ΒΆ

type Stats struct {
	DatabaseSize int64                 `json:"database_size"`
	LastUpdate   time.Time             `json:"last_update"`
	Indexes      map[string]StatsIndex `json:"indexes"`
}

Stats is the type that represent all stats

func (Stats) MarshalEasyJSON ΒΆ

func (v Stats) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Stats) MarshalJSON ΒΆ

func (v Stats) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Stats) UnmarshalEasyJSON ΒΆ

func (v *Stats) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Stats) UnmarshalJSON ΒΆ

func (v *Stats) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StatsIndex ΒΆ

type StatsIndex struct {
	NumberOfDocuments int64            `json:"numberOfDocuments"`
	IsIndexing        bool             `json:"isIndexing"`
	FieldsFrequency   map[string]int64 `json:"fieldsFrequency"`
}

StatsIndex is the type that represent the stats of an index in MeiliSearch

func (StatsIndex) MarshalEasyJSON ΒΆ

func (v StatsIndex) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StatsIndex) MarshalJSON ΒΆ

func (v StatsIndex) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StatsIndex) UnmarshalEasyJSON ΒΆ

func (v *StatsIndex) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StatsIndex) UnmarshalJSON ΒΆ

func (v *StatsIndex) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Str ΒΆ

type Str string

func (Str) MarshalJSON ΒΆ

func (s Str) MarshalJSON() ([]byte, error)

func (*Str) UnmarshalJSON ΒΆ

func (s *Str) UnmarshalJSON(data []byte) error

type StrsArr ΒΆ

type StrsArr []string

func (StrsArr) MarshalJSON ΒΆ

func (i StrsArr) MarshalJSON() ([]byte, error)

func (*StrsArr) UnmarshalJSON ΒΆ

func (i *StrsArr) UnmarshalJSON(data []byte) error

type Synonyms ΒΆ

type Synonyms map[string][]string

func (Synonyms) MarshalJSON ΒΆ

func (s Synonyms) MarshalJSON() ([]byte, error)

func (*Synonyms) UnmarshalJSON ΒΆ

func (s *Synonyms) UnmarshalJSON(data []byte) error

type Unknown ΒΆ

type Unknown map[string]interface{}

Unknown is unknown json type

type Update ΒΆ

type Update struct {
	Status      UpdateStatus `json:"status"`
	UpdateID    int64        `json:"updateID"`
	Type        Unknown      `json:"type"`
	Error       string       `json:"error"`
	EnqueuedAt  time.Time    `json:"enqueuedAt"`
	ProcessedAt time.Time    `json:"processedAt"`
}

Update indicate information about an update

func (Update) MarshalEasyJSON ΒΆ

func (v Update) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Update) MarshalJSON ΒΆ

func (v Update) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Update) UnmarshalEasyJSON ΒΆ

func (v *Update) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Update) UnmarshalJSON ΒΆ

func (v *Update) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type UpdateStatus ΒΆ

type UpdateStatus string

UpdateStatus is the status of an update.

const (
	// UpdateStatusUnknown is the default UpdateStatus, should not exist
	UpdateStatusUnknown UpdateStatus = "unknown"
	// UpdateStatusEnqueued means the server know the update but didn't handle it yet
	UpdateStatusEnqueued UpdateStatus = "enqueued"
	// UpdateStatusProcessed means the server has processed the update and all went well
	UpdateStatusProcessed UpdateStatus = "processed"
	// UpdateStatusFailed means the server has processed the update and an error has been reported
	UpdateStatusFailed UpdateStatus = "failed"
)

type Updates ΒΆ

type Updates []Update

func (Updates) MarshalJSON ΒΆ

func (u Updates) MarshalJSON() ([]byte, error)

func (*Updates) UnmarshalJSON ΒΆ

func (u *Updates) UnmarshalJSON(data []byte) error

type Version ΒΆ

type Version struct {
	CommitSha  string    `json:"commitSha"`
	BuildDate  time.Time `json:"buildDate"`
	PkgVersion string    `json:"pkgVersion"`
}

Version is the type that represents the versions in MeiliSearch

func (Version) MarshalEasyJSON ΒΆ

func (v Version) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Version) MarshalJSON ΒΆ

func (v Version) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Version) UnmarshalEasyJSON ΒΆ

func (v *Version) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Version) UnmarshalJSON ΒΆ

func (v *Version) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL