search

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2017 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package search provides search and index capabilities for goiardi.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializeMetrics added in v0.10.4

func InitializeMetrics(metricsBackend met.Backend)

InitializeMetrics initializes the statsd timers for search queries.

Types

type BasicQuery

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

BasicQuery is the no frills basic query type, without groups or ranges. Can contain regexp terms, however.

func (*BasicQuery) AddField

func (q *BasicQuery) AddField(s Field)

func (*BasicQuery) AddFuzzBoost

func (q *BasicQuery) AddFuzzBoost(o Op)

func (*BasicQuery) AddFuzzParam

func (q *BasicQuery) AddFuzzParam(s string)

func (*BasicQuery) AddOp

func (q *BasicQuery) AddOp(o Op)

func (*BasicQuery) AddTerm

func (q *BasicQuery) AddTerm(s Term)

func (*BasicQuery) AddTermOp

func (q *BasicQuery) AddTermOp(o Op)

func (*BasicQuery) IsIncomplete

func (q *BasicQuery) IsIncomplete() bool

func (*BasicQuery) Next

func (q *BasicQuery) Next() Queryable

func (*BasicQuery) Op

func (q *BasicQuery) Op() Op

func (*BasicQuery) SearchIndex

func (q *BasicQuery) SearchIndex(idxName string) (map[string]indexer.Document, error)

func (*BasicQuery) SearchResults added in v0.9.1

func (q *BasicQuery) SearchResults(curRes map[string]indexer.Document) (map[string]indexer.Document, error)

func (*BasicQuery) SetCompleted

func (q *BasicQuery) SetCompleted()

func (*BasicQuery) SetNext

func (q *BasicQuery) SetNext(n Queryable)

type Field

type Field string

Field is a field in a document or object to search for, like when searching for clients with "field:*".

func (Field) String

func (f Field) String() string

type GroupedQuery

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

GroupedQuery is for a query with grouped results.

func (*GroupedQuery) AddField

func (q *GroupedQuery) AddField(s Field)

func (*GroupedQuery) AddFuzzBoost

func (q *GroupedQuery) AddFuzzBoost(o Op)

func (*GroupedQuery) AddFuzzParam

func (q *GroupedQuery) AddFuzzParam(s string)

func (*GroupedQuery) AddOp

func (q *GroupedQuery) AddOp(o Op)

func (*GroupedQuery) AddTerm

func (q *GroupedQuery) AddTerm(s Term)

func (*GroupedQuery) AddTermOp

func (q *GroupedQuery) AddTermOp(o Op)

func (*GroupedQuery) IsIncomplete

func (q *GroupedQuery) IsIncomplete() bool

func (*GroupedQuery) Next

func (q *GroupedQuery) Next() Queryable

func (*GroupedQuery) Op

func (q *GroupedQuery) Op() Op

func (*GroupedQuery) SearchIndex

func (q *GroupedQuery) SearchIndex(idxName string) (map[string]indexer.Document, error)

func (*GroupedQuery) SearchResults added in v0.9.1

func (q *GroupedQuery) SearchResults(curRes map[string]indexer.Document) (map[string]indexer.Document, error)

func (*GroupedQuery) SetCompleted

func (q *GroupedQuery) SetCompleted()

func (*GroupedQuery) SetNext

func (q *GroupedQuery) SetNext(n Queryable)

type Op

type Op uint8

Op is a search operator

const (
	OpNotAnOp Op = iota
	OpUnaryNot
	OpUnaryReq
	OpUnaryPro
	OpBinAnd
	OpBinOr
	OpBoost
	OpFuzzy
	OpStartGroup
	OpEndGroup
	OpStartIncl
	OpEndIncl
	OpStartExcl
	OpEndExcl
)

Define the various search operations.

type PgQuery added in v0.10.0

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

type PostgresSearch added in v0.10.0

type PostgresSearch struct {
}

func (*PostgresSearch) GetEndpoints added in v0.10.0

func (p *PostgresSearch) GetEndpoints() []string

func (*PostgresSearch) Search added in v0.10.0

func (p *PostgresSearch) Search(idx string, q string, rows int, sortOrder string, start int, partialData map[string]interface{}) ([]map[string]interface{}, error)

type QueryTerm

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

QueryTerm is an individual query term and its operator.

type Queryable

type Queryable interface {
	// Search the index for the given term.
	SearchIndex(string) (map[string]indexer.Document, error)
	// Search for the given term from already gathered search results
	SearchResults(map[string]indexer.Document) (map[string]indexer.Document, error)
	// Add an operator to this query chain link.
	AddOp(Op)
	// Get this query chain link's op.
	Op() Op
	// Add a field to this query chain link.
	AddField(Field)
	// Add a term to this link.
	AddTerm(Term)
	// Add an operator to the query chain link's term.
	AddTermOp(Op)
	// Set the next query in the query chain.
	SetNext(Queryable)
	// Get the next link in the query chain.
	Next() Queryable
	// Is the query chain incomplete?
	IsIncomplete() bool
	// Sets the completed flag for this query chain on this link.
	SetCompleted()
	// Add fuzz boost to the query. NOTE: doesn't do much.
	AddFuzzBoost(Op)
	// Add a fuzz param to the query. NOTE: doesn't do much.
	AddFuzzParam(string)
}

Queryable defines an interface of methods all the query chain types have to be able to implement to search the index.

type RangeQuery

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

RangeQuery is for a Query a range of values.

func (*RangeQuery) AddField

func (q *RangeQuery) AddField(s Field)

func (*RangeQuery) AddFuzzBoost

func (q *RangeQuery) AddFuzzBoost(o Op)

func (*RangeQuery) AddFuzzParam

func (q *RangeQuery) AddFuzzParam(s string)

func (*RangeQuery) AddOp

func (q *RangeQuery) AddOp(o Op)

func (*RangeQuery) AddTerm

func (q *RangeQuery) AddTerm(s Term)

func (*RangeQuery) AddTermOp

func (q *RangeQuery) AddTermOp(o Op)

func (*RangeQuery) IsIncomplete

func (q *RangeQuery) IsIncomplete() bool

func (*RangeQuery) Next

func (q *RangeQuery) Next() Queryable

func (*RangeQuery) Op

func (q *RangeQuery) Op() Op

func (*RangeQuery) SearchIndex

func (q *RangeQuery) SearchIndex(idxName string) (map[string]indexer.Document, error)

func (*RangeQuery) SearchResults added in v0.9.1

func (q *RangeQuery) SearchResults(curRes map[string]indexer.Document) (map[string]indexer.Document, error)

func (*RangeQuery) SetCompleted

func (q *RangeQuery) SetCompleted()

func (*RangeQuery) SetNext

func (q *RangeQuery) SetNext(n Queryable)

type RangeTerm

type RangeTerm string

RangeTerm is a string, but describes a range to search over, like 1-10.

func (RangeTerm) String added in v0.10.0

func (r RangeTerm) String() string

type Searcher added in v0.10.0

type Searcher interface {
	Search(string, string, int, string, int, map[string]interface{}) ([]map[string]interface{}, error)
	GetEndpoints() []string
}

Searcher is an interface that any search backend needs to implement. It's up to the Searcher to use whatever backend it wants to return the desired results.

type SolrQuery

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

SolrQuery holds a parsed query and query chain to run against the index. It's called SolrQuery because the search queries use a subset of Solr's syntax.

type SubQuery

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

SubQuery is really just a marker in the chain of queries. Later it will be processed by itself though.

func (*SubQuery) AddField

func (q *SubQuery) AddField(s Field)

func (*SubQuery) AddFuzzBoost

func (q *SubQuery) AddFuzzBoost(o Op)

func (*SubQuery) AddFuzzParam

func (q *SubQuery) AddFuzzParam(s string)

func (*SubQuery) AddOp

func (q *SubQuery) AddOp(o Op)

func (*SubQuery) AddTerm

func (q *SubQuery) AddTerm(s Term)

func (*SubQuery) AddTermOp

func (q *SubQuery) AddTermOp(o Op)

func (*SubQuery) IsIncomplete

func (q *SubQuery) IsIncomplete() bool

func (*SubQuery) Next

func (q *SubQuery) Next() Queryable

func (*SubQuery) Op

func (q *SubQuery) Op() Op

func (*SubQuery) SearchIndex

func (q *SubQuery) SearchIndex(idxName string) (map[string]indexer.Document, error)

func (*SubQuery) SearchResults added in v0.9.1

func (q *SubQuery) SearchResults(curRes map[string]indexer.Document) (map[string]indexer.Document, error)

func (*SubQuery) SetCompleted

func (q *SubQuery) SetCompleted()

func (*SubQuery) SetNext

func (q *SubQuery) SetNext(n Queryable)

type Term

type Term string

Term is a basic search term string.

func (Term) String

func (t Term) String() string

type Token

type Token struct {
	QueryChain Queryable
	Latest     Queryable
}

Token is a parsed token from the solr query.

func (*Token) AddField

func (z *Token) AddField(s string)

func (*Token) AddOp

func (z *Token) AddOp(o Op)

func (*Token) AddRange

func (z *Token) AddRange(s string)

func (*Token) AddTerm

func (z *Token) AddTerm(s string)

func (*Token) AddTermOp

func (z *Token) AddTermOp(o Op)

func (*Token) EndSubQuery

func (z *Token) EndSubQuery()

func (*Token) Evaluate

func (z *Token) Evaluate() Queryable

func (*Token) SetCompleted

func (z *Token) SetCompleted()

func (*Token) StartBasic

func (z *Token) StartBasic()

func (*Token) StartGrouped

func (z *Token) StartGrouped()

func (*Token) StartRange

func (z *Token) StartRange(inclusive bool)

func (*Token) StartSubQuery

func (z *Token) StartSubQuery()

type Tokenizer

type Tokenizer struct {
	Token

	Buffer string

	Pretty bool
	// contains filtered or unexported fields
}

func (*Tokenizer) AST added in v0.11.5

func (t *Tokenizer) AST() *node32

func (*Tokenizer) Add added in v0.11.5

func (t *Tokenizer) Add(rule pegRule, begin, end, index uint32)

func (*Tokenizer) Execute

func (p *Tokenizer) Execute()

func (*Tokenizer) Init

func (p *Tokenizer) Init()

func (*Tokenizer) Parse

func (p *Tokenizer) Parse(rule ...int) error

func (*Tokenizer) PrettyPrintSyntaxTree added in v0.11.5

func (t *Tokenizer) PrettyPrintSyntaxTree(buffer string)

func (*Tokenizer) Print added in v0.11.5

func (t *Tokenizer) Print()

func (*Tokenizer) PrintSyntaxTree

func (p *Tokenizer) PrintSyntaxTree()

func (*Tokenizer) Reset

func (p *Tokenizer) Reset()

func (*Tokenizer) Tokens added in v0.11.5

func (t *Tokenizer) Tokens() []token32

func (*Tokenizer) Trim added in v0.11.5

func (t *Tokenizer) Trim(length uint32)

type TrieSearch added in v0.10.0

type TrieSearch struct {
}

func (*TrieSearch) GetEndpoints added in v0.10.0

func (t *TrieSearch) GetEndpoints() []string

GetEndpoints gets a list from the indexer of all the endpoints available to search, namely the defaults (node, role, client, environment) and any data bags.

func (*TrieSearch) Search added in v0.10.0

func (t *TrieSearch) Search(idx string, query string, rows int, sortOrder string, start int, partialData map[string]interface{}) ([]map[string]interface{}, error)

Search parses the given query string and search the given index for any matching results.

Jump to

Keyboard shortcuts

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