0
0
Fork 0

mapping: Fix closestDocMapping selecting wrong mapping

This commit is contained in:
Damien Tournoud 2017-12-13 13:45:58 -08:00
parent 6eea5b78da
commit 74b882640e
No known key found for this signature in database
GPG Key ID: A327B90267CB8EC2
2 changed files with 24 additions and 0 deletions

View File

@ -179,6 +179,7 @@ OUTER:
continue OUTER
}
}
break
}
return current
}

View File

@ -991,3 +991,26 @@ func TestMappingForNilTextMarshaler(t *testing.T) {
}
}
func TestClosestDocDynamicMapping(t *testing.T) {
mapping := NewIndexMapping()
mapping.IndexDynamic = false
mapping.DefaultMapping = NewDocumentStaticMapping()
mapping.DefaultMapping.AddFieldMappingsAt("foo", NewTextFieldMapping())
doc := document.NewDocument("x")
err := mapping.MapDocument(doc, map[string]interface{}{
"foo": "value",
"bar": map[string]string{
"foo": "value2",
"baz": "value3",
},
})
if err != nil {
t.Fatal(err)
}
if len(doc.Fields) != 1 {
t.Fatalf("expected 1 field, got: %d", len(doc.Fields))
}
}