mapping: Fix closestDocMapping selecting wrong mapping
This commit is contained in:
parent
6eea5b78da
commit
74b882640e
|
@ -179,6 +179,7 @@ OUTER:
|
|||
continue OUTER
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
return current
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue