0
0

honor the enabled=false flag at the top-level of doc mapping

fixes #331
This commit is contained in:
Marty Schoch 2016-01-21 19:16:16 -05:00
parent f0d6abff6f
commit 96577606c3
2 changed files with 27 additions and 6 deletions

View File

@ -402,6 +402,7 @@ func (im *IndexMapping) mapDocument(doc *document.Document, data interface{}) er
docType := im.determineType(data)
docMapping := im.mappingForType(docType)
walkContext := im.newWalkContext(doc, docMapping)
if docMapping.Enabled {
docMapping.walkDocument(data, []string{}, []uint64{}, walkContext)
// see if the _all field was disabled
@ -410,6 +411,7 @@ func (im *IndexMapping) mapDocument(doc *document.Document, data interface{}) er
field := document.NewCompositeFieldWithIndexingOptions("_all", true, []string{}, walkContext.excludedFromAll, document.IndexField|document.IncludeTermVectors)
doc.AddField(field)
}
}
return nil
}

View File

@ -402,3 +402,22 @@ func TestMappingBool(t *testing.T) {
t.Errorf("expected to find 2 fields, found %d", count)
}
}
func TestDisableDefaultMapping(t *testing.T) {
indexMapping := NewIndexMapping()
indexMapping.DefaultMapping.Enabled = false
data := map[string]string{
"name": "bleve",
}
doc := document.NewDocument("x")
err := indexMapping.mapDocument(doc, data)
if err != nil {
t.Error(err)
}
if len(doc.Fields) > 0 {
t.Errorf("expected no fields, got %d", len(doc.Fields))
}
}