-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdocument.go
More file actions
150 lines (117 loc) · 4.14 KB
/
Copy pathdocument.go
File metadata and controls
150 lines (117 loc) · 4.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// Copyright (c) 2015 Couchbase, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package index
import (
"net"
"time"
)
type Document interface {
ID() string
Size() int
VisitFields(visitor FieldVisitor)
VisitComposite(visitor CompositeFieldVisitor)
HasComposite() bool
NumPlainTextBytes() uint64
AddIDField()
StoredFieldsBytes() uint64
Indexed() bool
}
type FieldVisitor func(Field)
type Field interface {
Name() string
Value() []byte
ArrayPositions() []uint64
EncodedFieldType() byte
Analyze()
Options() FieldIndexingOptions
AnalyzedLength() int
AnalyzedTokenFrequencies() TokenFrequencies
NumPlainTextBytes() uint64
}
type CompositeFieldVisitor func(field CompositeField)
type CompositeField interface {
Field
Compose(field string, length int, freq TokenFrequencies)
}
type TextField interface {
Text() string
}
type NumericField interface {
Number() (float64, error)
}
type DateTimeField interface {
DateTime() (time.Time, string, error)
}
type BooleanField interface {
Boolean() (bool, error)
}
type GeoPointField interface {
Lon() (float64, error)
Lat() (float64, error)
}
type GeoShapeField interface {
GeoShape() (GeoJSON, error)
EncodedShape() []byte
}
// GeoShapeV2Field represents an analyzed geo shape field
type GeoShapeV2Field interface {
// InnerCells returns the covering cells fully contained within the shape
InnerCells() []uint64
// CrossCells returns the covering cells that overlap the shape's boundary
CrossCells() []uint64
// EncodedBoundingBox returns the serialized bounding box of the shape
EncodedBoundingBox() []byte
// EncodedShape returns the serialized shape
EncodedShape() []byte
// Scores returns the shape's inner and cross cell scores
Scores() (inner, cross uint64)
}
type IPField interface {
IP() (net.IP, error)
}
// TokenizableSpatialField is an optional interface for fields that
// supports pluggable custom hierarchial spatial token generation.
type TokenizableSpatialField interface {
// SetSpatialAnalyzerPlugin lets the index implementations to
// initialise relevant spatial analyzer plugins for the field
// to override the spatial token generations during the analysis phase.
SetSpatialAnalyzerPlugin(SpatialAnalyzerPlugin)
}
// SynonymField represents a field that contains a list of synonyms for a set of terms.
// Each SynonymField is generated from a single synonym definition, and its name corresponds
// to the synonym source to which the synonym definition belongs.
type SynonymField interface {
Field
// IterateSynonyms iterates over the synonyms for the term in the field.
// The provided visitor function is called with each term and its corresponding synonyms.
IterateSynonyms(visitor func(term string, synonyms []string))
}
// SynonymFieldVisitor is a function type used to visit a SynonymField within a document.
type SynonymFieldVisitor func(SynonymField)
// SynonymDocument represents a special type of document that contains synonym fields.
// Each SynonymField is a field with a list of synonyms for a set of terms.
// These fields are derived from synonym definitions, and their names correspond to the synonym sources.
type SynonymDocument interface {
Document
// VisitSynonymFields allows iteration over all synonym fields in the document.
// The provided visitor function is called for each synonym field.
VisitSynonymFields(visitor SynonymFieldVisitor)
}
// NestedDocument is a document that contains other documents inside it.
type NestedDocument interface {
Document
// VisitNestedDocuments allows iteration over all nested documents in the document.
// The provided visitor function is called for each nested document.
VisitNestedDocuments(visitor func(doc Document))
}