index

package
v0.0.0-...-080b9e8 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

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

Index controller

func NewIndex

func NewIndex(k types.IKuzzle) *Index

NewIndex instanciates a new index controller

func (*Index) Create

func (i *Index) Create(index string, options types.QueryOptions) error

Create a new empty data index, with no associated mapping.

Example
package main

import (
	"fmt"

	"github.com/kuzzleio/sdk-go/index"
	"github.com/kuzzleio/sdk-go/kuzzle"
	"github.com/kuzzleio/sdk-go/protocol/websocket"
)

func main() {
	conn := websocket.NewWebSocket("localhost:7512", nil)
	k, _ := kuzzle.NewKuzzle(conn, nil)
	i := index.NewIndex(k)
	err := i.Create("index", nil)
	if err != nil {
		fmt.Println(err.Error())
		return
	}
}

func (*Index) Delete

func (i *Index) Delete(index string, options types.QueryOptions) error

Delete the given index

Example
package main

import (
	"fmt"

	"github.com/kuzzleio/sdk-go/index"
	"github.com/kuzzleio/sdk-go/kuzzle"
	"github.com/kuzzleio/sdk-go/protocol/websocket"
)

func main() {
	conn := websocket.NewWebSocket("localhost:7512", nil)
	k, _ := kuzzle.NewKuzzle(conn, nil)
	i := index.NewIndex(k)
	i.Create("index", nil)
	err := i.Delete("index", nil)
	if err != nil {
		fmt.Println(err.Error())
		return
	}
}

func (*Index) Exists

func (i *Index) Exists(index string, options types.QueryOptions) (bool, error)

Exists check if the index exists

Example
package main

import (
	"fmt"

	"github.com/kuzzleio/sdk-go/index"
	"github.com/kuzzleio/sdk-go/kuzzle"
	"github.com/kuzzleio/sdk-go/protocol/websocket"
)

func main() {
	conn := websocket.NewWebSocket("localhost:7512", nil)
	k, _ := kuzzle.NewKuzzle(conn, nil)
	i := index.NewIndex(k)
	i.Create("index", nil)
	_, err := i.Exists("index", nil)
	if err != nil {
		fmt.Println(err.Error())
		return
	}
}

func (*Index) List

func (i *Index) List(options types.QueryOptions) ([]string, error)

List all index

Example
package main

import (
	"fmt"

	"github.com/kuzzleio/sdk-go/index"
	"github.com/kuzzleio/sdk-go/internal"
	"github.com/kuzzleio/sdk-go/kuzzle"
)

func main() {
	c := &internal.MockedConnection{}
	k, _ := kuzzle.NewKuzzle(c, nil)

	i := index.NewIndex(k)
	res, err := i.List(nil)

	if err != nil {
		fmt.Println(err.Error())
		return
	}

	fmt.Println(res)
}

func (*Index) MDelete

func (i *Index) MDelete(indexes []string, options types.QueryOptions) ([]string, error)

MDelete deletes all matching indices at once

Example
package main

import (
	"fmt"

	"github.com/kuzzleio/sdk-go/index"
	"github.com/kuzzleio/sdk-go/kuzzle"
	"github.com/kuzzleio/sdk-go/protocol/websocket"
)

func main() {
	conn := websocket.NewWebSocket("localhost:7512", nil)
	k, _ := kuzzle.NewKuzzle(conn, nil)
	i := index.NewIndex(k)
	i.Create("index1", nil)
	i.Create("index2", nil)
	indexes := []string{
		"index1",
		"index2",
	}
	_, err := i.MDelete(indexes, nil)
	if err != nil {
		fmt.Println(err.Error())
		return
	}
}

Jump to

Keyboard shortcuts

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