Document Payloads

    Since the scoring functions already have access to the DocumentMetaData, which contains document flags and score, We can add custom payloads that can be evaluated in run-time.

    Payloads are NOT indexed and are not treated by the engine in any way. They are simply there for the purpose of evaluating them in query time, and optionally retrieving them. They can be JSON objects, strings, or preferably, if you are interested in fast evaluation, some sort of binary encoded data which is fast to decode.

    When inserting a document using FT.ADD, you can ask RediSearch to store an arbitrary binary safe string as the document payload. This is done with the keyword:

    Note

    Currently, scoring functions cannot be dynamically added, and forking the engine and replacing them is required.

    DocumentMetaData includes a few fields, one of them being the payload. It wraps a simple byte array with arbitrary length:

    When searching, it is possible to request the document payloads from the engine.

    This is done by adding the keyword to .

    If is set, the payloads follow the document id in the returned result. If is set as well, the payloads follow the scores. e.g.: