/ releasenotes / notes / document-backward-compatible-07c4151e98ef8511.yaml
document-backward-compatible-07c4151e98ef8511.yaml
 1  ---
 2  prelude: >
 3    The `Document` serialisation has been changed quite a bit, this will make it easier to implement
 4    new Document Stores.
 5  
 6    The most notable change is that the `Document.flatten()` method has been removed.
 7    `Document.to_dict()` now has a `flatten` parameter, that defaults to `True` for backward compatibility.
 8    It will flatten metadata keys at the same level of other `Document` fields when converting to `dict`.
 9  
10    `to_json` and `from_json` have been removed, as `to_dict` and `from_dict` already handle serialisation
11    of `dataframe` and `blob` fields.
12    Now `metadata` must only contain primitives that can be serialised to JSON with no custom encoders.
13    If any Document Store needs custom serialisation they can implement their own logic.
14  
15    `Document` has also been made backward compatible so that it can be created using dictionaries
16    structured as the legacy 1.x `Document`. The legacy fields will be converted automatically to
17    their new counterparts, or ignored if there's none.
18  preview:
19    - |
20      Refactor Document serialisation and make it backward compatible with Haystack 1.x