query

package
v2.3.7 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: Apache-2.0 Imports: 22 Imported by: 77

Documentation

Index

Constants

View Source
const (
	// Document must satisfy AT LEAST ONE of term searches.
	MatchQueryOperatorOr = MatchQueryOperator(0)
	// Document must satisfy ALL of term searches.
	MatchQueryOperatorAnd = MatchQueryOperator(1)
)

Variables

View Source
var MaxRFC3339CompatibleTime time.Time
View Source
var MinRFC3339CompatibleTime time.Time
View Source
var QueryDateTimeFormat = time.RFC3339

QueryDateTimeFormat controls the format when Marshaling to JSON

View Source
var QueryDateTimeParser = optional.Name

QueryDateTimeParser controls the default query date time parser

Functions

func DumpQuery

func DumpQuery(m mapping.IndexMapping, query Query) (string, error)

DumpQuery returns a string representation of the query tree, where query string queries have been expanded into base queries. The output format is meant for debugging purpose and may change in the future.

func SetLog

func SetLog(l *log.Logger)

SetLog sets the logger used for logging by default log messages are sent to ioutil.Discard

Types

type BleveQueryTime

type BleveQueryTime struct {
	time.Time
}

func (*BleveQueryTime) MarshalJSON

func (t *BleveQueryTime) MarshalJSON() ([]byte, error)

func (*BleveQueryTime) UnmarshalJSON

func (t *BleveQueryTime) UnmarshalJSON(data []byte) error

type BoolFieldQuery

type BoolFieldQuery struct {
	Bool     bool   `json:"bool"`
	FieldVal string `json:"field,omitempty"`
	BoostVal *Boost `json:"boost,omitempty"`
}

func NewBoolFieldQuery

func NewBoolFieldQuery(val bool) *BoolFieldQuery

NewBoolFieldQuery creates a new Query for boolean fields

func (*BoolFieldQuery) Boost

func (q *BoolFieldQuery) Boost() float64

func (*BoolFieldQuery) Field

func (q *BoolFieldQuery) Field() string

func (*BoolFieldQuery) Searcher

func (*BoolFieldQuery) SetBoost

func (q *BoolFieldQuery) SetBoost(b float64)

func (*BoolFieldQuery) SetField

func (q *BoolFieldQuery) SetField(f string)

type BooleanQuery

type BooleanQuery struct {
	Must     Query  `json:"must,omitempty"`
	Should   Query  `json:"should,omitempty"`
	MustNot  Query  `json:"must_not,omitempty"`
	BoostVal *Boost `json:"boost,omitempty"`
	// contains filtered or unexported fields
}

func NewBooleanQuery

func NewBooleanQuery(must []Query, should []Query, mustNot []Query) *BooleanQuery

NewBooleanQuery creates a compound Query composed of several other Query objects. Result documents must satisfy ALL of the must Queries. Result documents must satisfy NONE of the must not Queries. Result documents that ALSO satisfy any of the should Queries will score higher.

func NewBooleanQueryForQueryString

func NewBooleanQueryForQueryString(must []Query, should []Query, mustNot []Query) *BooleanQuery

func (*BooleanQuery) AddMust

func (q *BooleanQuery) AddMust(m ...Query)

func (*BooleanQuery) AddMustNot

func (q *BooleanQuery) AddMustNot(m ...Query)

func (*BooleanQuery) AddShould

func (q *BooleanQuery) AddShould(m ...Query)

func (*BooleanQuery) Boost

func (q *BooleanQuery) Boost() float64

func (*BooleanQuery) Searcher

func (*BooleanQuery) SetBoost

func (q *BooleanQuery) SetBoost(b float64)

func (*BooleanQuery) SetMinShould

func (q *BooleanQuery) SetMinShould(minShould float64)

SetMinShould requires that at least minShould of the should Queries must be satisfied.

func (*BooleanQuery) UnmarshalJSON

func (q *BooleanQuery) UnmarshalJSON(data []byte) error

func (*BooleanQuery) Validate

func (q *BooleanQuery) Validate() error

type Boost

type Boost float64

func (*Boost) GoString

func (b *Boost) GoString() string

func (*Boost) Value

func (b *Boost) Value() float64

type BoostableQuery

type BoostableQuery interface {
	Query
	SetBoost(b float64)
	Boost() float64
}

A BoostableQuery represents a Query which can be boosted relative to other queries.

type ConjunctionQuery

type ConjunctionQuery struct {
	Conjuncts []Query `json:"conjuncts"`
	BoostVal  *Boost  `json:"boost,omitempty"`
	// contains filtered or unexported fields
}

func NewConjunctionQuery

func NewConjunctionQuery(conjuncts []Query) *ConjunctionQuery

NewConjunctionQuery creates a new compound Query. Result documents must satisfy all of the queries.

func (*ConjunctionQuery) AddQuery

func (q *ConjunctionQuery) AddQuery(aq ...Query)

func (*ConjunctionQuery) Boost

func (q *ConjunctionQuery) Boost() float64

func (*ConjunctionQuery) Searcher

func (*ConjunctionQuery) SetBoost

func (q *ConjunctionQuery) SetBoost(b float64)

func (*ConjunctionQuery) UnmarshalJSON

func (q *ConjunctionQuery) UnmarshalJSON(data []byte) error

func (*ConjunctionQuery) Validate

func (q *ConjunctionQuery) Validate() error

type DateRangeQuery

type DateRangeQuery struct {
	Start          BleveQueryTime `json:"start,omitempty"`
	End            BleveQueryTime `json:"end,omitempty"`
	InclusiveStart *bool          `json:"inclusive_start,omitempty"`
	InclusiveEnd   *bool          `json:"inclusive_end,omitempty"`
	FieldVal       string         `json:"field,omitempty"`
	BoostVal       *Boost         `json:"boost,omitempty"`
}

func NewDateRangeInclusiveQuery

func NewDateRangeInclusiveQuery(start, end time.Time, startInclusive, endInclusive *bool) *DateRangeQuery

NewDateRangeInclusiveQuery creates a new Query for ranges of date values. Date strings are parsed using the DateTimeParser configured in the

top-level config.QueryDateTimeParser

Either, but not both endpoints can be nil. startInclusive and endInclusive control inclusion of the endpoints.

func NewDateRangeQuery

func NewDateRangeQuery(start, end time.Time) *DateRangeQuery

NewDateRangeQuery creates a new Query for ranges of date values. Date strings are parsed using the DateTimeParser configured in the

top-level config.QueryDateTimeParser

Either, but not both endpoints can be nil.

func (*DateRangeQuery) Boost

func (q *DateRangeQuery) Boost() float64

func (*DateRangeQuery) Field

func (q *DateRangeQuery) Field() string

func (*DateRangeQuery) Searcher

func (*DateRangeQuery) SetBoost

func (q *DateRangeQuery) SetBoost(b float64)

func (*DateRangeQuery) SetField

func (q *DateRangeQuery) SetField(f string)

func (*DateRangeQuery) Validate

func (q *DateRangeQuery) Validate() error

type DisjunctionQuery

type DisjunctionQuery struct {
	Disjuncts []Query `json:"disjuncts"`
	BoostVal  *Boost  `json:"boost,omitempty"`
	Min       float64 `json:"min"`
	// contains filtered or unexported fields
}

func NewDisjunctionQuery

func NewDisjunctionQuery(disjuncts []Query) *DisjunctionQuery

NewDisjunctionQuery creates a new compound Query. Result documents satisfy at least one Query.

func (*DisjunctionQuery) AddQuery

func (q *DisjunctionQuery) AddQuery(aq ...Query)

func (*DisjunctionQuery) Boost

func (q *DisjunctionQuery) Boost() float64

func (*DisjunctionQuery) Searcher

func (*DisjunctionQuery) SetBoost

func (q *DisjunctionQuery) SetBoost(b float64)

func (*DisjunctionQuery) SetMin

func (q *DisjunctionQuery) SetMin(m float64)

func (*DisjunctionQuery) UnmarshalJSON

func (q *DisjunctionQuery) UnmarshalJSON(data []byte) error

func (*DisjunctionQuery) Validate

func (q *DisjunctionQuery) Validate() error

type DocIDQuery

type DocIDQuery struct {
	IDs      []string `json:"ids"`
	BoostVal *Boost   `json:"boost,omitempty"`
}

func NewDocIDQuery

func NewDocIDQuery(ids []string) *DocIDQuery

NewDocIDQuery creates a new Query object returning indexed documents among the specified set. Combine it with ConjunctionQuery to restrict the scope of other queries output.

func (*DocIDQuery) Boost

func (q *DocIDQuery) Boost() float64

func (*DocIDQuery) Searcher

func (*DocIDQuery) SetBoost

func (q *DocIDQuery) SetBoost(b float64)

type FieldableQuery

type FieldableQuery interface {
	Query
	SetField(f string)
	Field() string
}

A FieldableQuery represents a Query which can be restricted to a single field.

type FuzzyQuery

type FuzzyQuery struct {
	Term      string `json:"term"`
	Prefix    int    `json:"prefix_length"`
	Fuzziness int    `json:"fuzziness"`
	FieldVal  string `json:"field,omitempty"`
	BoostVal  *Boost `json:"boost,omitempty"`
}

func NewFuzzyQuery

func NewFuzzyQuery(term string) *FuzzyQuery

NewFuzzyQuery creates a new Query which finds documents containing terms within a specific fuzziness of the specified term. The default fuzziness is 1.

The current implementation uses Levenshtein edit distance as the fuzziness metric.

func (*FuzzyQuery) Boost

func (q *FuzzyQuery) Boost() float64

func (*FuzzyQuery) Field

func (q *FuzzyQuery) Field() string

func (*FuzzyQuery) Searcher

func (*FuzzyQuery) SetBoost

func (q *FuzzyQuery) SetBoost(b float64)

func (*FuzzyQuery) SetField

func (q *FuzzyQuery) SetField(f string)

func (*FuzzyQuery) SetFuzziness

func (q *FuzzyQuery) SetFuzziness(f int)

func (*FuzzyQuery) SetPrefix

func (q *FuzzyQuery) SetPrefix(p int)

type GeoBoundingBoxQuery

type GeoBoundingBoxQuery struct {
	TopLeft     []float64 `json:"top_left,omitempty"`
	BottomRight []float64 `json:"bottom_right,omitempty"`
	FieldVal    string    `json:"field,omitempty"`
	BoostVal    *Boost    `json:"boost,omitempty"`
}

func NewGeoBoundingBoxQuery

func NewGeoBoundingBoxQuery(topLeftLon, topLeftLat, bottomRightLon, bottomRightLat float64) *GeoBoundingBoxQuery

func (*GeoBoundingBoxQuery) Boost

func (q *GeoBoundingBoxQuery) Boost() float64

func (*GeoBoundingBoxQuery) Field

func (q *GeoBoundingBoxQuery) Field() string

func (*GeoBoundingBoxQuery) Searcher

func (*GeoBoundingBoxQuery) SetBoost

func (q *GeoBoundingBoxQuery) SetBoost(b float64)

func (*GeoBoundingBoxQuery) SetField

func (q *GeoBoundingBoxQuery) SetField(f string)

func (*GeoBoundingBoxQuery) UnmarshalJSON

func (q *GeoBoundingBoxQuery) UnmarshalJSON(data []byte) error

func (*GeoBoundingBoxQuery) Validate

func (q *GeoBoundingBoxQuery) Validate() error

type GeoBoundingPolygonQuery

type GeoBoundingPolygonQuery struct {
	Points   []geo.Point `json:"polygon_points"`
	FieldVal string      `json:"field,omitempty"`
	BoostVal *Boost      `json:"boost,omitempty"`
}

func NewGeoBoundingPolygonQuery

func NewGeoBoundingPolygonQuery(points []geo.Point) *GeoBoundingPolygonQuery

func (*GeoBoundingPolygonQuery) Boost

func (q *GeoBoundingPolygonQuery) Boost() float64

func (*GeoBoundingPolygonQuery) Field

func (q *GeoBoundingPolygonQuery) Field() string

func (*GeoBoundingPolygonQuery) Searcher

func (*GeoBoundingPolygonQuery) SetBoost

func (q *GeoBoundingPolygonQuery) SetBoost(b float64)

func (*GeoBoundingPolygonQuery) SetField

func (q *GeoBoundingPolygonQuery) SetField(f string)

func (*GeoBoundingPolygonQuery) UnmarshalJSON

func (q *GeoBoundingPolygonQuery) UnmarshalJSON(data []byte) error

func (*GeoBoundingPolygonQuery) Validate

func (q *GeoBoundingPolygonQuery) Validate() error

type GeoDistanceQuery

type GeoDistanceQuery struct {
	Location []float64 `json:"location,omitempty"`
	Distance string    `json:"distance,omitempty"`
	FieldVal string    `json:"field,omitempty"`
	BoostVal *Boost    `json:"boost,omitempty"`
}

func NewGeoDistanceQuery

func NewGeoDistanceQuery(lon, lat float64, distance string) *GeoDistanceQuery

func (*GeoDistanceQuery) Boost

func (q *GeoDistanceQuery) Boost() float64

func (*GeoDistanceQuery) Field

func (q *GeoDistanceQuery) Field() string

func (*GeoDistanceQuery) Searcher

func (*GeoDistanceQuery) SetBoost

func (q *GeoDistanceQuery) SetBoost(b float64)

func (*GeoDistanceQuery) SetField

func (q *GeoDistanceQuery) SetField(f string)

func (*GeoDistanceQuery) UnmarshalJSON

func (q *GeoDistanceQuery) UnmarshalJSON(data []byte) error

func (*GeoDistanceQuery) Validate

func (q *GeoDistanceQuery) Validate() error

type GeoShapeQuery added in v2.3.3

type GeoShapeQuery struct {
	Geometry Geometry `json:"geometry"`
	FieldVal string   `json:"field,omitempty"`
	BoostVal *Boost   `json:"boost,omitempty"`
}

func NewGeoShapeCircleQuery added in v2.3.3

func NewGeoShapeCircleQuery(coordinates []float64, radius,
	relation string) (*GeoShapeQuery, error)

NewGeoShapeCircleQuery creates a geoshape query for the given center point and the radius. Radius formats supported: "5in" "5inch" "7yd" "7yards" "9ft" "9feet" "11km" "11kilometers" "3nm" "3nauticalmiles" "13mm" "13millimeters" "15cm" "15centimeters" "17mi" "17miles" "19m" "19meters" If the unit cannot be determined, the entire string is parsed and the unit of meters is assumed.

func NewGeoShapeQuery added in v2.3.3

func NewGeoShapeQuery(coordinates [][][][]float64, typ,
	relation string) (*GeoShapeQuery, error)

NewGeoShapeQuery creates a geoshape query for the given shape type. This method can be used for creating geoshape queries for shape types like: point, linestring, polygon, multipoint, multilinestring, multipolygon and envelope.

func NewGeometryCollectionQuery added in v2.3.3

func NewGeometryCollectionQuery(coordinates [][][][][]float64, types []string,
	relation string) (*GeoShapeQuery, error)

NewGeometryCollectionQuery creates a geoshape query for the given geometrycollection coordinates and types.

func (*GeoShapeQuery) Boost added in v2.3.3

func (q *GeoShapeQuery) Boost() float64

func (*GeoShapeQuery) Field added in v2.3.3

func (q *GeoShapeQuery) Field() string

func (*GeoShapeQuery) Searcher added in v2.3.3

func (*GeoShapeQuery) SetBoost added in v2.3.3

func (q *GeoShapeQuery) SetBoost(b float64)

func (*GeoShapeQuery) SetField added in v2.3.3

func (q *GeoShapeQuery) SetField(f string)

func (*GeoShapeQuery) Validate added in v2.3.3

func (q *GeoShapeQuery) Validate() error

type Geometry added in v2.3.3

type Geometry struct {
	Shape    index.GeoJSON `json:"shape"`
	Relation string        `json:"relation"`
}

func (*Geometry) UnmarshalJSON added in v2.3.3

func (q *Geometry) UnmarshalJSON(data []byte) error

type IPRangeQuery added in v2.3.0

type IPRangeQuery struct {
	CIDR     string `json:"cidr, omitempty"`
	FieldVal string `json:"field,omitempty"`
	BoostVal *Boost `json:"boost,omitempty"`
}

func NewIPRangeQuery added in v2.3.0

func NewIPRangeQuery(cidr string) *IPRangeQuery

func (*IPRangeQuery) Boost added in v2.3.0

func (q *IPRangeQuery) Boost() float64

func (*IPRangeQuery) Field added in v2.3.0

func (q *IPRangeQuery) Field() string

func (*IPRangeQuery) Searcher added in v2.3.0

func (*IPRangeQuery) SetBoost added in v2.3.0

func (q *IPRangeQuery) SetBoost(b float64)

func (*IPRangeQuery) SetField added in v2.3.0

func (q *IPRangeQuery) SetField(f string)

func (*IPRangeQuery) Validate added in v2.3.0

func (q *IPRangeQuery) Validate() error

type MatchAllQuery

type MatchAllQuery struct {
	BoostVal *Boost `json:"boost,omitempty"`
}

func NewMatchAllQuery

func NewMatchAllQuery() *MatchAllQuery

NewMatchAllQuery creates a Query which will match all documents in the index.

func (*MatchAllQuery) Boost

func (q *MatchAllQuery) Boost() float64

func (*MatchAllQuery) MarshalJSON

func (q *MatchAllQuery) MarshalJSON() ([]byte, error)

func (*MatchAllQuery) Searcher

func (*MatchAllQuery) SetBoost

func (q *MatchAllQuery) SetBoost(b float64)

type MatchNoneQuery

type MatchNoneQuery struct {
	BoostVal *Boost `json:"boost,omitempty"`
}

func NewMatchNoneQuery

func NewMatchNoneQuery() *MatchNoneQuery

NewMatchNoneQuery creates a Query which will not match any documents in the index.

func (*MatchNoneQuery) Boost

func (q *MatchNoneQuery) Boost() float64

func (*MatchNoneQuery) MarshalJSON

func (q *MatchNoneQuery) MarshalJSON() ([]byte, error)

func (*MatchNoneQuery) Searcher

func (*MatchNoneQuery) SetBoost

func (q *MatchNoneQuery) SetBoost(b float64)

type MatchPhraseQuery

type MatchPhraseQuery struct {
	MatchPhrase string `json:"match_phrase"`
	FieldVal    string `json:"field,omitempty"`
	Analyzer    string `json:"analyzer,omitempty"`
	BoostVal    *Boost `json:"boost,omitempty"`
}

func NewMatchPhraseQuery

func NewMatchPhraseQuery(matchPhrase string) *MatchPhraseQuery

NewMatchPhraseQuery creates a new Query object for matching phrases in the index. An Analyzer is chosen based on the field. Input text is analyzed using this analyzer. Token terms resulting from this analysis are used to build a search phrase. Result documents must match this phrase. Queried field must have been indexed with IncludeTermVectors set to true.

func (*MatchPhraseQuery) Boost

func (q *MatchPhraseQuery) Boost() float64

func (*MatchPhraseQuery) Field

func (q *MatchPhraseQuery) Field() string

func (*MatchPhraseQuery) Searcher

func (*MatchPhraseQuery) SetBoost

func (q *MatchPhraseQuery) SetBoost(b float64)

func (*MatchPhraseQuery) SetField

func (q *MatchPhraseQuery) SetField(f string)

type MatchQuery

type MatchQuery struct {
	Match     string             `json:"match"`
	FieldVal  string             `json:"field,omitempty"`
	Analyzer  string             `json:"analyzer,omitempty"`
	BoostVal  *Boost             `json:"boost,omitempty"`
	Prefix    int                `json:"prefix_length"`
	Fuzziness int                `json:"fuzziness"`
	Operator  MatchQueryOperator `json:"operator,omitempty"`
}

func NewMatchQuery

func NewMatchQuery(match string) *MatchQuery

NewMatchQuery creates a Query for matching text. An Analyzer is chosen based on the field. Input text is analyzed using this analyzer. Token terms resulting from this analysis are used to perform term searches. Result documents must satisfy at least one of these term searches.

func (*MatchQuery) Boost

func (q *MatchQuery) Boost() float64

func (*MatchQuery) Field

func (q *MatchQuery) Field() string

func (*MatchQuery) Searcher

func (*MatchQuery) SetBoost

func (q *MatchQuery) SetBoost(b float64)

func (*MatchQuery) SetField

func (q *MatchQuery) SetField(f string)

func (*MatchQuery) SetFuzziness

func (q *MatchQuery) SetFuzziness(f int)

func (*MatchQuery) SetOperator

func (q *MatchQuery) SetOperator(operator MatchQueryOperator)

func (*MatchQuery) SetPrefix

func (q *MatchQuery) SetPrefix(p int)

type MatchQueryOperator

type MatchQueryOperator int

func (MatchQueryOperator) MarshalJSON

func (o MatchQueryOperator) MarshalJSON() ([]byte, error)

func (*MatchQueryOperator) UnmarshalJSON

func (o *MatchQueryOperator) UnmarshalJSON(data []byte) error

type MultiPhraseQuery

type MultiPhraseQuery struct {
	Terms    [][]string `json:"terms"`
	Field    string     `json:"field,omitempty"`
	BoostVal *Boost     `json:"boost,omitempty"`
}

func NewMultiPhraseQuery

func NewMultiPhraseQuery(terms [][]string, field string) *MultiPhraseQuery

NewMultiPhraseQuery creates a new Query for finding term phrases in the index. It is like PhraseQuery, but each position in the phrase may be satisfied by a list of terms as opposed to just one. At least one of the terms must exist in the correct order, at the correct index offsets, in the specified field. Queried field must have been indexed with IncludeTermVectors set to true.

func (*MultiPhraseQuery) Boost

func (q *MultiPhraseQuery) Boost() float64

func (*MultiPhraseQuery) Searcher

func (*MultiPhraseQuery) SetBoost

func (q *MultiPhraseQuery) SetBoost(b float64)

func (*MultiPhraseQuery) UnmarshalJSON

func (q *MultiPhraseQuery) UnmarshalJSON(data []byte) error

func (*MultiPhraseQuery) Validate

func (q *MultiPhraseQuery) Validate() error

type NumericRangeQuery

type NumericRangeQuery struct {
	Min          *float64 `json:"min,omitempty"`
	Max          *float64 `json:"max,omitempty"`
	InclusiveMin *bool    `json:"inclusive_min,omitempty"`
	InclusiveMax *bool    `json:"inclusive_max,omitempty"`
	FieldVal     string   `json:"field,omitempty"`
	BoostVal     *Boost   `json:"boost,omitempty"`
}

func NewNumericRangeInclusiveQuery

func NewNumericRangeInclusiveQuery(min, max *float64, minInclusive, maxInclusive *bool) *NumericRangeQuery

NewNumericRangeInclusiveQuery creates a new Query for ranges of numeric values. Either, but not both endpoints can be nil. Control endpoint inclusion with inclusiveMin, inclusiveMax.

func NewNumericRangeQuery

func NewNumericRangeQuery(min, max *float64) *NumericRangeQuery

NewNumericRangeQuery creates a new Query for ranges of numeric values. Either, but not both endpoints can be nil. The minimum value is inclusive. The maximum value is exclusive.

func (*NumericRangeQuery) Boost

func (q *NumericRangeQuery) Boost() float64

func (*NumericRangeQuery) Field

func (q *NumericRangeQuery) Field() string

func (*NumericRangeQuery) Searcher

func (*NumericRangeQuery) SetBoost

func (q *NumericRangeQuery) SetBoost(b float64)

func (*NumericRangeQuery) SetField

func (q *NumericRangeQuery) SetField(f string)

func (*NumericRangeQuery) Validate

func (q *NumericRangeQuery) Validate() error

type PhraseQuery

type PhraseQuery struct {
	Terms    []string `json:"terms"`
	Field    string   `json:"field,omitempty"`
	BoostVal *Boost   `json:"boost,omitempty"`
}

func NewPhraseQuery

func NewPhraseQuery(terms []string, field string) *PhraseQuery

NewPhraseQuery creates a new Query for finding exact term phrases in the index. The provided terms must exist in the correct order, at the correct index offsets, in the specified field. Queried field must have been indexed with IncludeTermVectors set to true.

func (*PhraseQuery) Boost

func (q *PhraseQuery) Boost() float64

func (*PhraseQuery) Searcher

func (*PhraseQuery) SetBoost

func (q *PhraseQuery) SetBoost(b float64)

func (*PhraseQuery) UnmarshalJSON

func (q *PhraseQuery) UnmarshalJSON(data []byte) error

func (*PhraseQuery) Validate

func (q *PhraseQuery) Validate() error

type PrefixQuery

type PrefixQuery struct {
	Prefix   string `json:"prefix"`
	FieldVal string `json:"field,omitempty"`
	BoostVal *Boost `json:"boost,omitempty"`
}

func NewPrefixQuery

func NewPrefixQuery(prefix string) *PrefixQuery

NewPrefixQuery creates a new Query which finds documents containing terms that start with the specified prefix.

func (*PrefixQuery) Boost

func (q *PrefixQuery) Boost() float64

func (*PrefixQuery) Field

func (q *PrefixQuery) Field() string

func (*PrefixQuery) Searcher

func (*PrefixQuery) SetBoost

func (q *PrefixQuery) SetBoost(b float64)

func (*PrefixQuery) SetField

func (q *PrefixQuery) SetField(f string)

type Query

type Query interface {
	Searcher(ctx context.Context, i index.IndexReader, m mapping.IndexMapping,
		options search.SearcherOptions) (search.Searcher, error)
}

A Query represents a description of the type and parameters for a query into the index.

func ParseQuery

func ParseQuery(input []byte) (Query, error)

ParseQuery deserializes a JSON representation of a Query object.

type QueryStringQuery

type QueryStringQuery struct {
	Query    string `json:"query"`
	BoostVal *Boost `json:"boost,omitempty"`
}

func NewQueryStringQuery

func NewQueryStringQuery(query string) *QueryStringQuery

NewQueryStringQuery creates a new Query used for finding documents that satisfy a query string. The query string is a small query language for humans.

func (*QueryStringQuery) Boost

func (q *QueryStringQuery) Boost() float64

func (*QueryStringQuery) Parse

func (q *QueryStringQuery) Parse() (Query, error)

func (*QueryStringQuery) Searcher

func (*QueryStringQuery) SetBoost

func (q *QueryStringQuery) SetBoost(b float64)

func (*QueryStringQuery) Validate

func (q *QueryStringQuery) Validate() error

type RegexpQuery

type RegexpQuery struct {
	Regexp   string `json:"regexp"`
	FieldVal string `json:"field,omitempty"`
	BoostVal *Boost `json:"boost,omitempty"`
}

func NewRegexpQuery

func NewRegexpQuery(regexp string) *RegexpQuery

NewRegexpQuery creates a new Query which finds documents containing terms that match the specified regular expression. The regexp pattern SHOULD NOT include ^ or $ modifiers, the search will only match entire terms even without them.

func (*RegexpQuery) Boost

func (q *RegexpQuery) Boost() float64

func (*RegexpQuery) Field

func (q *RegexpQuery) Field() string

func (*RegexpQuery) Searcher

func (*RegexpQuery) SetBoost

func (q *RegexpQuery) SetBoost(b float64)

func (*RegexpQuery) SetField

func (q *RegexpQuery) SetField(f string)

func (*RegexpQuery) Validate

func (q *RegexpQuery) Validate() error

type TermQuery

type TermQuery struct {
	Term     string `json:"term"`
	FieldVal string `json:"field,omitempty"`
	BoostVal *Boost `json:"boost,omitempty"`
}

func NewTermQuery

func NewTermQuery(term string) *TermQuery

NewTermQuery creates a new Query for finding an exact term match in the index.

func (*TermQuery) Boost

func (q *TermQuery) Boost() float64

func (*TermQuery) Field

func (q *TermQuery) Field() string

func (*TermQuery) Searcher

func (*TermQuery) SetBoost

func (q *TermQuery) SetBoost(b float64)

func (*TermQuery) SetField

func (q *TermQuery) SetField(f string)

type TermRangeQuery

type TermRangeQuery struct {
	Min          string `json:"min,omitempty"`
	Max          string `json:"max,omitempty"`
	InclusiveMin *bool  `json:"inclusive_min,omitempty"`
	InclusiveMax *bool  `json:"inclusive_max,omitempty"`
	FieldVal     string `json:"field,omitempty"`
	BoostVal     *Boost `json:"boost,omitempty"`
}

func NewTermRangeInclusiveQuery

func NewTermRangeInclusiveQuery(min, max string, minInclusive, maxInclusive *bool) *TermRangeQuery

NewTermRangeInclusiveQuery creates a new Query for ranges of numeric values. Either, but not both endpoints can be nil. Control endpoint inclusion with inclusiveMin, inclusiveMax.

func NewTermRangeQuery

func NewTermRangeQuery(min, max string) *TermRangeQuery

NewTermRangeQuery creates a new Query for ranges of text term values. Either, but not both endpoints can be nil. The minimum value is inclusive. The maximum value is exclusive.

func (*TermRangeQuery) Boost

func (q *TermRangeQuery) Boost() float64

func (*TermRangeQuery) Field

func (q *TermRangeQuery) Field() string

func (*TermRangeQuery) Searcher

func (*TermRangeQuery) SetBoost

func (q *TermRangeQuery) SetBoost(b float64)

func (*TermRangeQuery) SetField

func (q *TermRangeQuery) SetField(f string)

func (*TermRangeQuery) Validate

func (q *TermRangeQuery) Validate() error

type ValidatableQuery

type ValidatableQuery interface {
	Query
	Validate() error
}

A ValidatableQuery represents a Query which can be validated prior to execution.

type WildcardQuery

type WildcardQuery struct {
	Wildcard string `json:"wildcard"`
	FieldVal string `json:"field,omitempty"`
	BoostVal *Boost `json:"boost,omitempty"`
}

func NewWildcardQuery

func NewWildcardQuery(wildcard string) *WildcardQuery

NewWildcardQuery creates a new Query which finds documents containing terms that match the specified wildcard. In the wildcard pattern '*' will match any sequence of 0 or more characters, and '?' will match any single character.

func (*WildcardQuery) Boost

func (q *WildcardQuery) Boost() float64

func (*WildcardQuery) Field

func (q *WildcardQuery) Field() string

func (*WildcardQuery) Searcher

func (*WildcardQuery) SetBoost

func (q *WildcardQuery) SetBoost(b float64)

func (*WildcardQuery) SetField

func (q *WildcardQuery) SetField(f string)

func (*WildcardQuery) Validate

func (q *WildcardQuery) Validate() error

Jump to

Keyboard shortcuts

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