summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/blevesearch/bleve/mapping/field.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/blevesearch/bleve/mapping/field.go')
-rw-r--r--vendor/github.com/blevesearch/bleve/mapping/field.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/vendor/github.com/blevesearch/bleve/mapping/field.go b/vendor/github.com/blevesearch/bleve/mapping/field.go
index 0976cd6fd7..9f1928ca5b 100644
--- a/vendor/github.com/blevesearch/bleve/mapping/field.go
+++ b/vendor/github.com/blevesearch/bleve/mapping/field.go
@@ -21,6 +21,7 @@ import (
"github.com/blevesearch/bleve/analysis"
"github.com/blevesearch/bleve/document"
+ "github.com/blevesearch/bleve/geo"
)
// control the default behavior for dynamic fields (those not explicitly mapped)
@@ -124,6 +125,16 @@ func newBooleanFieldMappingDynamic(im *IndexMappingImpl) *FieldMapping {
return rv
}
+// NewGeoPointFieldMapping returns a default field mapping for geo points
+func NewGeoPointFieldMapping() *FieldMapping {
+ return &FieldMapping{
+ Type: "geopoint",
+ Store: true,
+ Index: true,
+ IncludeInAll: true,
+ }
+}
+
// Options returns the indexing options for this field.
func (fm *FieldMapping) Options() document.IndexingOptions {
var rv document.IndexingOptions
@@ -208,6 +219,20 @@ func (fm *FieldMapping) processBoolean(propertyValueBool bool, pathString string
}
}
+func (fm *FieldMapping) processGeoPoint(propertyMightBeGeoPoint interface{}, pathString string, path []string, indexes []uint64, context *walkContext) {
+ lon, lat, found := geo.ExtractGeoPoint(propertyMightBeGeoPoint)
+ if found {
+ fieldName := getFieldName(pathString, path, fm)
+ options := fm.Options()
+ field := document.NewGeoPointFieldWithIndexingOptions(fieldName, indexes, lon, lat, options)
+ context.doc.AddField(field)
+
+ if !fm.IncludeInAll {
+ context.excludedFromAll = append(context.excludedFromAll, fieldName)
+ }
+ }
+}
+
func (fm *FieldMapping) analyzerForField(path []string, context *walkContext) *analysis.Analyzer {
analyzerName := fm.Analyzer
if analyzerName == "" {