mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-12-05 14:39:23 -05:00
Term buckets on both engines: bleve folds them from doc values (its facets read numbers as prefix-coded terms), OpenSearch uses terms aggregations. A request gets every bucket, up to 65535 per space (the OpenSearch default for search.max_buckets, held on bleve as well); beyond that it is refused. The proto gains AggregationOption, BucketDefinition (sort, minimum count), AggregationResult and Bucket. The new aggregation package merges the per-space results by position, so several aggregations on one field stay apart, and shapes them per BucketDefinition (minimum count, sort, size). It also validates aggregations against the index mapping (a field the index knows and a client may name, of a type whose values are buckets; the mapping overrides mark the internal fields): the search service relies on it, the graph endpoint asks it first to save the round trip, next to its own checks against the spec, and with the field names of the request so an error reads like the request. A request names a field like the driveItem property, exactly so. A number is keyed as it is, a bool as true or false on both engines, an empty value is no bucket. Pinned in the parity suite as AGG-01 to 03, 17, 34, 37 and 39; the paging rows AGG-41 to 43 pin the first commit through the same matrix machinery, which also shortens long answer lists in the README.
67 lines
2.7 KiB
Go
67 lines
2.7 KiB
Go
// Package mapping builds search index mappings for bleve and OpenSearch from
|
|
// a Go struct via reflection. Field names come from json tags; the caller
|
|
// provides overrides for fields that need a specific type or analyzer.
|
|
package mapping
|
|
|
|
// Field type constants used in FieldOpts.Type. An empty Type means the type
|
|
// is inferred from the Go field via reflection.
|
|
const (
|
|
TypeKeyword = "keyword"
|
|
TypeFulltext = "fulltext"
|
|
TypePath = "path"
|
|
TypeWildcard = "wildcard"
|
|
TypeNumeric = "numeric"
|
|
TypeDatetime = "datetime"
|
|
TypeBool = "bool"
|
|
TypeObject = "object"
|
|
TypeGeopoint = "geopoint"
|
|
)
|
|
|
|
// LowercaseSuffix names the lowercased sibling of a keyword/path field.
|
|
const LowercaseSuffix = "_lowercase"
|
|
|
|
// WordsSuffix names the word-broken sibling of a keyword field.
|
|
const WordsSuffix = "_words"
|
|
|
|
// WordsAnalyzer names the analyzer both engines register for the words sibling.
|
|
const WordsAnalyzer = "words"
|
|
|
|
// PathAnalyzer names the analyzer both engines register for TypePath fields:
|
|
// every ancestor prefix of a path is a term, so one term query matches a
|
|
// folder and its descendants.
|
|
const PathAnalyzer = "path_hierarchy"
|
|
|
|
// FieldOpts overrides the default type inference for a struct field. Keys in
|
|
// the override map are json-tag names (e.g. "Name", "location", "audio.artist"),
|
|
// not Go field names.
|
|
type FieldOpts struct {
|
|
// Type is one of the Type* constants. Empty means "infer from Go type".
|
|
Type string
|
|
|
|
// CaseInsensitive additionally indexes a lowercased <name>_lowercase sibling
|
|
// for case-insensitive search; the case-preserved base is always indexed.
|
|
// On by default for keyword/path fields, KQL searches case-insensitively;
|
|
// false opts a field out (ids, paths).
|
|
CaseInsensitive *bool
|
|
|
|
// NoWordBreaker is SharePoint's switch, with its default: a keyword field
|
|
// additionally indexes a <name>_words sibling split into lowercased words
|
|
// (no stemming), so a single word matches a value that contains it,
|
|
// "report" finds "Report.txt"; true opts a field out and leaves it one
|
|
// whole value (tags, ids, paths). The base stays the whole value for
|
|
// returning and aggregating; wildcards and whole-value matches use the
|
|
// _lowercase sibling. Keyword only.
|
|
NoWordBreaker *bool
|
|
|
|
// IncludeInAll controls bleve's _all field inclusion. Nil means "use the
|
|
// bleve default for this field type". Has no effect on OpenSearch.
|
|
IncludeInAll *bool
|
|
|
|
// Internal marks index housekeeping no client names: not aggregated on,
|
|
// not filtered to. KQL still searches it.
|
|
Internal bool
|
|
}
|
|
|
|
func (o FieldOpts) caseInsensitive() bool { return o.CaseInsensitive == nil || *o.CaseInsensitive }
|
|
func (o FieldOpts) wordBroken() bool { return o.NoWordBreaker == nil || !*o.NoWordBreaker }
|