api

package
v0.0.0-...-b0aaf25 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2015 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Overview

*

Copyright 2012 Matthew Baird

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*

Index

Constants

View Source
const (
	Version         = "0.0.1"
	DefaultProtocol = "http"
	DefaultDomain   = "localhost"
	DefaultPort     = "9200"

	// A decay duration of zero results in the default behaviour
	DefaultDecayDuration = 0
)

Variables

View Source
var (

	// Maintain these for backwards compatibility
	Protocol string = DefaultProtocol
	Domain   string = DefaultDomain
	Port     string = DefaultPort

	// Store a slice of hosts in a hostpool
	Hosts []string

	// To compute the weighting scores, we perform a weighted average of recent response times,
	// over the course of `DecayDuration`. DecayDuration may be set to 0 to use the default
	// value of 5 minutes. The EpsilonValueCalculator uses this to calculate a score
	// from the weighted average response time.
	DecayDuration time.Duration = time.Duration(DefaultDecayDuration * time.Second)
)

Functions

func DoCommand

func DoCommand(method string, url string, data interface{}) ([]byte, error)

func Pretty

func Pretty(pretty bool) string

func Scan

func Scan(scan int) string

func Scroll

func Scroll(duration string) string

func SetHosts

func SetHosts(newhosts []string)

Types

type BaseResponse

type BaseResponse struct {
	Ok      bool             `json:"ok"`
	Index   string           `json:"_index,omitempty"`
	Type    string           `json:"_type,omitempty"`
	Id      string           `json:"_id,omitempty"`
	Source  *json.RawMessage `json:"_source,omitempty"` // depends on the schema you've defined
	Version int              `json:"_version,omitempty"`
	Found   bool             `json:"found,omitempty"`
	Exists  bool             `json:"exists,omitempty"`
	Created bool             `json:"created,omitempty"`
	Matches []string         `json:"matches,omitempty"` // percolate matches
}

func Exists

func Exists(pretty bool, index string, _type string, id string) (BaseResponse, error)

The API also allows to check for the existance of a document using HEAD This appears to be broken in the current version of elasticsearch 0.19.10, currently returning nothing

type Error

type Error struct {
	Status  int    `json:"status"` // HTTP status code (200, 403, ...)
	Message string `json:"error"`  // The human readable error message
}

func (*Error) Error

func (err *Error) Error() string

type Explaination

type Explaination struct {
	Value       float32        `json:"value"`
	Description string         `json:"description"`
	Details     []Explaination `json:"details,omitempty"`
}

type Facets

type Facets struct {
	Tag Terms `json:"tag"`
}

type Filter

type Filter struct {
	Term Term `json:"term"`
}

type Match

type Match struct {
	OK           bool         `json:"ok"`
	Matches      []string     `json:"matches"`
	Explaination Explaination `json:"explaination,omitempty"`
}

type Query

type Query struct {
	Query Term `json:"query"`
}

type Request

type Request struct {
	*http.Request
	// contains filtered or unexported fields
}

func ElasticSearchRequest

func ElasticSearchRequest(method, path string) (*Request, error)

func (*Request) Do

func (r *Request) Do(v interface{}) (int, []byte, error)

func (*Request) SetBody

func (r *Request) SetBody(body io.Reader)

func (*Request) SetBodyJson

func (r *Request) SetBodyJson(data interface{}) error

func (*Request) SetBodyString

func (r *Request) SetBodyString(body string)

type SearchRequest

type SearchRequest struct {
	From   int    `json:"from,omitempty"`
	Size   int    `json:"size,omitempty"`
	Query  Query  `json:"query,omitempty"`
	Filter Filter `json:"filter,omitempty"`
}

type Status

type Status struct {
	Total      int `json:"total"`
	Successful int `json:"successful"`
	Failed     int `json:"failed"`
}

type Term

type Term struct {
	Term string `json:"term"`
}

type Terms

type Terms struct {
	Terms string `json:"terms"`
}

Jump to

Keyboard shortcuts

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