search

package
v0.10.0-pre3 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2015 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package search provides search and index capabilities for goiardi.

Index

Constants

View Source
const END_SYMBOL rune = 4

Variables

View Source
var Rul3s = [...]string{
	"Unknown",
	"q",
	"body",
	"expression",
	"term",
	"field",
	"field_norm",
	"field_group",
	"field_range",
	"field_inc_range",
	"field_exc_range",
	"field_name",
	"range_value",
	"group",
	"operation",
	"unary_op",
	"binary_op",
	"boolean_operator",
	"or_operator",
	"and_operator",
	"not_op",
	"not_operator",
	"bang_operator",
	"required_op",
	"required_operator",
	"prohibited_op",
	"prohibited_operator",
	"boost_op",
	"fuzzy_op",
	"fuzzy_param",
	"string",
	"keyword",
	"valid_letter",
	"start_letter",
	"end_letter",
	"special_char",
	"open_paren",
	"close_paren",
	"open_incl",
	"close_incl",
	"open_excl",
	"close_excl",
	"space",
	"PegText",
	"Action0",
	"Action1",
	"Action2",
	"Action3",
	"Action4",
	"Action5",
	"Action6",
	"Action7",
	"Action8",
	"Action9",
	"Action10",
	"Action11",
	"Action12",
	"Action13",
	"Action14",
	"Action15",
	"Action16",
	"Action17",
	"Action18",
	"Action19",
	"Action20",

	"Pre_",
	"_In_",
	"_Suf",
}

Functions

This section is empty.

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 Rule

type Rule uint8

The rule types inferred from the grammar are below.

const (
	RuleUnknown Rule = iota
	Ruleq
	Rulebody
	Ruleexpression
	Ruleterm
	Rulefield
	Rulefield_norm
	Rulefield_group
	Rulefield_range
	Rulefield_inc_range
	Rulefield_exc_range
	Rulefield_name
	Rulerange_value
	Rulegroup
	Ruleoperation
	Ruleunary_op
	Rulebinary_op
	Ruleboolean_operator
	Ruleor_operator
	Ruleand_operator
	Rulenot_op
	Rulenot_operator
	Rulebang_operator
	Rulerequired_op
	Rulerequired_operator
	Ruleprohibited_op
	Ruleprohibited_operator
	Ruleboost_op
	Rulefuzzy_op
	Rulefuzzy_param
	Rulestring
	Rulekeyword
	Rulevalid_letter
	Rulestart_letter
	Ruleend_letter
	Rulespecial_char
	Ruleopen_paren
	Ruleclose_paren
	Ruleopen_incl
	Ruleclose_incl
	Ruleopen_excl
	Ruleclose_excl
	Rulespace
	RulePegText
	RuleAction0
	RuleAction1
	RuleAction2
	RuleAction3
	RuleAction4
	RuleAction5
	RuleAction6
	RuleAction7
	RuleAction8
	RuleAction9
	RuleAction10
	RuleAction11
	RuleAction12
	RuleAction13
	RuleAction14
	RuleAction15
	RuleAction16
	RuleAction17
	RuleAction18
	RuleAction19
	RuleAction20

	RulePre_
	Rule_In_
	Rule_Suf
)

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 State16

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

func (*State16) GetToken32

func (t *State16) GetToken32() token32

func (*State16) String

func (t *State16) String() string

type State32

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

func (*State32) GetToken32

func (t *State32) GetToken32() token32

func (*State32) String

func (t *State32) String() string

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 TokenTree

type TokenTree interface {
	Print()
	PrintSyntax()
	PrintSyntaxTree(buffer string)
	Add(rule Rule, begin, end, next, depth int)
	Expand(index int) TokenTree
	Tokens() <-chan token32
	Error() []token32
	// contains filtered or unexported methods
}

type Tokenizer

type Tokenizer struct {
	Token

	Buffer string

	Parse func(rule ...int) error
	Reset func()
	TokenTree
	// contains filtered or unexported fields
}

func (*Tokenizer) Execute

func (p *Tokenizer) Execute()

func (*Tokenizer) Highlighter

func (p *Tokenizer) Highlighter()

func (*Tokenizer) Init

func (p *Tokenizer) Init()

func (*Tokenizer) PrintSyntaxTree

func (p *Tokenizer) PrintSyntaxTree()

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