bugfixes more search results and dump restore options
This commit is contained in:
parent
f4fcf0d9a8
commit
3cd460318a
124 changed files with 3915 additions and 9579 deletions
38
vendor/github.com/blevesearch/bleve/query_date_range.go
generated
vendored
38
vendor/github.com/blevesearch/bleve/query_date_range.go
generated
vendored
|
|
@ -26,12 +26,12 @@ type dateRangeQuery struct {
|
|||
InclusiveEnd *bool `json:"inclusive_end,omitempty"`
|
||||
FieldVal string `json:"field,omitempty"`
|
||||
BoostVal float64 `json:"boost,omitempty"`
|
||||
DateTimeParser *string `json:"datetime_parser,omitempty"`
|
||||
}
|
||||
|
||||
// NewDateRangeQuery creates a new Query for ranges
|
||||
// of date values.
|
||||
// A DateTimeParser is chosen based on the field.
|
||||
// Date strings are parsed using the DateTimeParser configured in the
|
||||
// top-level config.QueryDateTimeParser
|
||||
// Either, but not both endpoints can be nil.
|
||||
func NewDateRangeQuery(start, end *string) *dateRangeQuery {
|
||||
return NewDateRangeInclusiveQuery(start, end, nil, nil)
|
||||
|
|
@ -39,7 +39,8 @@ func NewDateRangeQuery(start, end *string) *dateRangeQuery {
|
|||
|
||||
// NewDateRangeInclusiveQuery creates a new Query for ranges
|
||||
// of date values.
|
||||
// A DateTimeParser is chosen based on the field.
|
||||
// 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 NewDateRangeInclusiveQuery(start, end *string, startInclusive, endInclusive *bool) *dateRangeQuery {
|
||||
|
|
@ -72,15 +73,9 @@ func (q *dateRangeQuery) SetField(f string) Query {
|
|||
|
||||
func (q *dateRangeQuery) Searcher(i index.IndexReader, m *IndexMapping, explain bool) (search.Searcher, error) {
|
||||
|
||||
dateTimeParserName := ""
|
||||
if q.DateTimeParser != nil {
|
||||
dateTimeParserName = *q.DateTimeParser
|
||||
} else {
|
||||
dateTimeParserName = m.datetimeParserNameForPath(q.FieldVal)
|
||||
}
|
||||
dateTimeParser := m.dateTimeParserNamed(dateTimeParserName)
|
||||
if dateTimeParser == nil {
|
||||
return nil, fmt.Errorf("no datetime parser named '%s' registered", *q.DateTimeParser)
|
||||
min, max, err := q.parseEndpoints()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
field := q.FieldVal
|
||||
|
|
@ -88,30 +83,43 @@ func (q *dateRangeQuery) Searcher(i index.IndexReader, m *IndexMapping, explain
|
|||
field = m.DefaultField
|
||||
}
|
||||
|
||||
return searchers.NewNumericRangeSearcher(i, min, max, q.InclusiveStart, q.InclusiveEnd, field, q.BoostVal, explain)
|
||||
}
|
||||
|
||||
func (q *dateRangeQuery) parseEndpoints() (*float64, *float64, error) {
|
||||
dateTimeParser, err := Config.Cache.DateTimeParserNamed(Config.QueryDateTimeParser)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// now parse the endpoints
|
||||
min := math.Inf(-1)
|
||||
max := math.Inf(1)
|
||||
if q.Start != nil && *q.Start != "" {
|
||||
startTime, err := dateTimeParser.ParseDateTime(*q.Start)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
min = numeric_util.Int64ToFloat64(startTime.UnixNano())
|
||||
}
|
||||
if q.End != nil && *q.End != "" {
|
||||
endTime, err := dateTimeParser.ParseDateTime(*q.End)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
max = numeric_util.Int64ToFloat64(endTime.UnixNano())
|
||||
}
|
||||
|
||||
return searchers.NewNumericRangeSearcher(i, &min, &max, q.InclusiveStart, q.InclusiveEnd, field, q.BoostVal, explain)
|
||||
return &min, &max, nil
|
||||
}
|
||||
|
||||
func (q *dateRangeQuery) Validate() error {
|
||||
if q.Start == nil && q.Start == q.End {
|
||||
return fmt.Errorf("must specify start or end")
|
||||
}
|
||||
_, _, err := q.parseEndpoints()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue