gxelasticsearch

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

2017-04-02 02:04 package gxelasticsearch provides a Elasticsearch driver

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EsClient

type EsClient struct {
	*es.Client
	// contains filtered or unexported fields
}

func CreateEsClient

func CreateEsClient(hosts []string) (EsClient, error)

func (EsClient) BulkInsert

func (ec EsClient) BulkInsert(index, typ string, arr []interface{}) error

BulkInsert 批量插入@arr !!! 如果@arr[0]的类型是string 或者 []byte,则被当做Json String类型直接存进去 https://www.elastic.co/guide/en/elasticsearch/guide/current/bulk.html A good place to start is with batches of 1,000 to 5,000 documents

func (EsClient) CreateEsIndex

func (ec EsClient) CreateEsIndex(index string, shardNum, replicaNum, refreshInterval int32) error

func (EsClient) CreateEsIndexWithTimestamp

func (ec EsClient) CreateEsIndexWithTimestamp(index string, shardNum, replicaNum, refreshInterval int32,
	indexType, timestampField, timestampFormat string) error

func (EsClient) DeleteEsIndex

func (ec EsClient) DeleteEsIndex(index string) error

func (EsClient) Insert

func (ec EsClient) Insert(index, typ string, msg interface{}) error

InsertWithDocId 插入@msg !!! 如果@msg的类型是string 或者 []byte,则被当做Json String类型直接存进去

func (EsClient) InsertWithDocId

func (ec EsClient) InsertWithDocId(index, typ, docID string, msg interface{}) error

InsertWithDocId 插入@msg时候指定@docID !!! 如果@msg的类型是string 或者 []byte,则被当做Json String类型直接存进去

func (EsClient) SetTemplate

func (ec EsClient) SetTemplate(index, template string, force bool) error

[template](https://github.com/inloco/kafka-elasticsearch-injector/blob/master/src/elasticsearch/elasticsearch_test.go#L39) `

{
	"template": "my-topic-*",
	"settings": {},
	"mappings": {
	  "my-topic": {
		"_source": {
		  "enabled": "true"
		},
		"dynamic_templates": [
		  {
			"strings": {
			  "mapping": {
				"index": "not_analyzed",
				"type": "string"
			  },
			  "match_mapping_type": "string"
			}
		  }
		],
		"properties": {
		  "id": {
		  	"type": "keyword"
		  }
		}
	  }
	},
	"aliases": {}
}

` set mapping & settings

Jump to

Keyboard shortcuts

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