Documentation ¶
Overview ¶
Parse Solr queries with the PEG generated from 'search/search-parse.peg', located in search-parse.peg.go. To have changes to seach-parse.peg reflected in search-parse.peg.go, install peg from https://github.com/pointlander/peg and run 'peg -switch -inline search-parse.peg'.
Package search provides search and index capabilities for goiardi.
Index ¶
- Constants
- Variables
- func GetEndpoints() []string
- func Search(idx string, q string) ([]indexer.Indexable, error)
- type BasicQuery
- func (q *BasicQuery) AddField(s Field)
- func (q *BasicQuery) AddFuzzBoost(o Op)
- func (q *BasicQuery) AddFuzzParam(s string)
- func (q *BasicQuery) AddOp(o Op)
- func (q *BasicQuery) AddTerm(s Term)
- func (q *BasicQuery) AddTermOp(o Op)
- func (q *BasicQuery) IsIncomplete() bool
- func (q *BasicQuery) Next() Queryable
- func (q *BasicQuery) Op() Op
- func (q *BasicQuery) SearchIndex(idxName string) (map[string]*indexer.IdxDoc, error)
- func (q *BasicQuery) SetCompleted()
- func (q *BasicQuery) SetNext(n Queryable)
- type Field
- type GroupQueryHolder
- type GroupedQuery
- func (q *GroupedQuery) AddField(s Field)
- func (q *GroupedQuery) AddFuzzBoost(o Op)
- func (q *GroupedQuery) AddFuzzParam(s string)
- func (q *GroupedQuery) AddOp(o Op)
- func (q *GroupedQuery) AddTerm(s Term)
- func (q *GroupedQuery) AddTermOp(o Op)
- func (q *GroupedQuery) IsIncomplete() bool
- func (q *GroupedQuery) Next() Queryable
- func (q *GroupedQuery) Op() Op
- func (q *GroupedQuery) SearchIndex(idxName string) (map[string]*indexer.IdxDoc, error)
- func (q *GroupedQuery) SetCompleted()
- func (q *GroupedQuery) SetNext(n Queryable)
- type Op
- type QueryTerm
- type Queryable
- type RangeQuery
- func (q *RangeQuery) AddField(s Field)
- func (q *RangeQuery) AddFuzzBoost(o Op)
- func (q *RangeQuery) AddFuzzParam(s string)
- func (q *RangeQuery) AddOp(o Op)
- func (q *RangeQuery) AddTerm(s Term)
- func (q *RangeQuery) AddTermOp(o Op)
- func (q *RangeQuery) IsIncomplete() bool
- func (q *RangeQuery) Next() Queryable
- func (q *RangeQuery) Op() Op
- func (q *RangeQuery) SearchIndex(idxName string) (map[string]*indexer.IdxDoc, error)
- func (q *RangeQuery) SetCompleted()
- func (q *RangeQuery) SetNext(n Queryable)
- type RangeTerm
- type Rule
- type SolrQuery
- type State16
- type State32
- type SubQuery
- func (q *SubQuery) AddField(s Field)
- func (q *SubQuery) AddFuzzBoost(o Op)
- func (q *SubQuery) AddFuzzParam(s string)
- func (q *SubQuery) AddOp(o Op)
- func (q *SubQuery) AddTerm(s Term)
- func (q *SubQuery) AddTermOp(o Op)
- func (q *SubQuery) IsIncomplete() bool
- func (q *SubQuery) Next() Queryable
- func (q *SubQuery) Op() Op
- func (q *SubQuery) SearchIndex(idxName string) (map[string]*indexer.IdxDoc, error)
- func (q *SubQuery) SetCompleted()
- func (q *SubQuery) SetNext(n Queryable)
- type Term
- type Token
- func (z *Token) AddField(s string)
- func (z *Token) AddOp(o Op)
- func (z *Token) AddRange(s string)
- func (z *Token) AddTerm(s string)
- func (z *Token) AddTermOp(o Op)
- func (z *Token) EndSubQuery()
- func (z *Token) Evaluate() Queryable
- func (z *Token) SetCompleted()
- func (z *Token) StartBasic()
- func (z *Token) StartGrouped()
- func (z *Token) StartRange(inclusive bool)
- func (z *Token) StartSubQuery()
- type TokenTree
- type Tokenizer
Constants ¶
const END_SYMBOL rune = 4
Variables ¶
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 ¶
func GetEndpoints ¶
func GetEndpoints() []string
Get a list from the indexer of all the endpoints available to search.
Types ¶
type BasicQuery ¶
type BasicQuery struct {
// contains filtered or unexported fields
}
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 (*BasicQuery) SetCompleted ¶
func (q *BasicQuery) SetCompleted()
func (*BasicQuery) SetNext ¶
func (q *BasicQuery) SetNext(n Queryable)
type GroupQueryHolder ¶
type GroupQueryHolder struct {
// contains filtered or unexported fields
}
type GroupedQuery ¶
type GroupedQuery struct {
// contains filtered or unexported fields
}
Query 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 (*GroupedQuery) SetCompleted ¶
func (q *GroupedQuery) SetCompleted()
func (*GroupedQuery) SetNext ¶
func (q *GroupedQuery) SetNext(n Queryable)
type QueryTerm ¶
type QueryTerm struct {
// contains filtered or unexported fields
}
An individual query term and its operator.
type Queryable ¶
type Queryable interface { // Search the index for the given term. SearchIndex(string) (map[string]*indexer.IdxDoc, 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) }
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
}
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 (*RangeQuery) SetCompleted ¶
func (q *RangeQuery) SetCompleted()
func (*RangeQuery) SetNext ¶
func (q *RangeQuery) SetNext(n Queryable)
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 SolrQuery ¶
type SolrQuery struct {
// contains filtered or unexported fields
}
Holds a parsed query and query chain to run against the index.
type State16 ¶
type State16 struct {
// contains filtered or unexported fields
}
func (*State16) GetToken32 ¶
func (t *State16) GetToken32() token32
type State32 ¶
type State32 struct {
// contains filtered or unexported fields
}
func (*State32) GetToken32 ¶
func (t *State32) GetToken32() token32
type SubQuery ¶
type SubQuery struct {
// contains filtered or unexported fields
}
Subquery's really just a marker in the chain of queries. Later it will be processed by itself though.
func (*SubQuery) AddFuzzBoost ¶
func (*SubQuery) AddFuzzParam ¶
func (*SubQuery) IsIncomplete ¶
func (*SubQuery) SearchIndex ¶
func (*SubQuery) SetCompleted ¶
func (q *SubQuery) SetCompleted()
type Token ¶
Hold parsed tokens from the solr query
func (*Token) EndSubQuery ¶
func (z *Token) EndSubQuery()
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 (*Token) StartSubQuery ¶
func (z *Token) StartSubQuery()