escrud

package module
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package escrud provides simple CRUD operations and search function to work with Elastic Search

Index

Constants

This section is empty.

Variables

View Source
var Es *elasticsearch.Client

Functions

func Connect added in v2.0.1

func Connect(host string, port int)

func Create

func Create(index string, id string, data []byte) (err error)

Create should contain a valid JSON with key {..."id":your_unique_id}

func Exists

func Exists(index string, id string) (exists bool, err error)

Exists checks if there's a document with such id in such an index

func Source

func Source(index, id string) ([]byte, error)

Types

type Created

type Created struct {
	ID string `json:"_id"`
}

type Deleted

type Deleted struct {
	Index   string `json:"_index"`
	ID      string `json:"_id"`
	Version int    `json:"_version"`
	Result  string `json:"result"`
}

func Delete

func Delete(index, id string) (Deleted, error)

type Got

type Got struct {
	Index   string      `json:"_index"`
	ID      string      `json:"_id"`
	Version int         `json:"_version"`
	Source  interface{} `json:"_source"`
}

func Read

func Read(index, id string) (Got, error)

type Updated

type Updated struct {
	Index   string `json:"_index"`
	ID      string `json:"_id"`
	Version int    `json:"_version"`
	Result  string `json:"result"`
}

func Update

func Update(index, id string, data []byte) (Updated, error)

Jump to

Keyboard shortcuts

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