/
position_increment_gap.go
59 lines (53 loc) · 2.63 KB
/
position_increment_gap.go
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
package picker
import "github.com/chanced/dynamic"
const DefaultPositionIncrementGap = float64(100)
// WithPositionIncrementGap is a mapping with the position_increment_gap
// parameter
//
// Analyzed text fields take term positions into account, in order to be able to
// support proximity or phrase queries. When indexing text fields with multiple
// values a "fake" gap is added between the values to prevent most phrase
// queries from matching across the values. The size of this gap is configured
// using position_increment_gap and defaults to 100.
//
// https://www.elastic.co/guide/en/elasticsearch/reference/current/position-increment-gap.html
type WithPositionIncrementGap interface {
// PositionIncrementGap is the number of fake term position which should be
// inserted between each element of an array of strings. Defaults to the
// position_increment_gap configured on the analyzer which defaults to 100.
// 100 was chosen because it prevents phrase queries with reasonably large
// slops (less than 100) from matching terms across field values.
//
// https://www.elastic.co/guide/en/elasticsearch/reference/current/position-increment-gap.html
PositionIncrementGap() int
// SetPositionIncrementGap sets the PositionIncrementGap Value to v
SetPositionIncrementGap(v interface{}) error
}
// positionIncrementGapParam is a mixin that adds the position_increment_gap
// parameter
//
// Analyzed text fields take term positions into account, in order to be able to
// support proximity or phrase queries. When indexing text fields with multiple
// values a "fake" gap is added between the values to prevent most phrase
// queries from matching across the values. The size of this gap is configured
// using position_increment_gap and defaults to 100.
//
// https://www.elastic.co/guide/en/elasticsearch/reference/current/position-increment-gap.html
type positionIncrementGapParam struct {
positionIncrementGap dynamic.Number
}
// PositionIncrementGap is the number of fake term position which should be
// inserted between each element of an array of strings. Defaults to the
// position_increment_gap configured on the analyzer which defaults to 100.
// 100 was chosen because it prevents phrase queries with reasonably large
// slops (less than 100) from matching terms across field values.
func (pig positionIncrementGapParam) PositionIncrementGap() float64 {
if f, ok := pig.positionIncrementGap.Float64(); ok {
return f
}
return DefaultPositionIncrementGap
}
// SetPositionIncrementGap sets the PositionIncrementGap Value to v
func (pig *positionIncrementGapParam) SetPositionIncrementGap(v interface{}) error {
return pig.positionIncrementGap.Set(v)
}