Search code examples
jsonsolrschemafieldtype

what's delimited_payload_string fieldtype in solr


I'm new to solr. Can someone explain what the delimited_payload_string field type is?

For example, can I store the following JSON object as a multi-valued delimited_payload_string?

"classifications": [
{"code": "RESTAURANT", "names": [{"nameLocale": "en-US", "name": "restaurant"}, {"nameLocale": "en-US", "name": "fast food"}]}
]

Solution

  • A delimited payload string is for attaching a payload to a specific field - a payload is an additional value that isn't visible in the document, but can be used by custom plugins. From Solr Payloads

    Available alongside the positionally related information is an optional general purpose byte array. At the lowest-level, Lucene allows any term in any position to store whatever bytes it’d like in its payload area. This byte array can be retrieved as the term’s position is accessed.

    [...]

    A payload’s primary use case is to affect relevancy scoring; there are also other very interesting ways to use payloads, discussed here later. Built-in at Lucene’s core scoring mechanism is float Similarity#computePayloadFactor() which until now has not been used by any production code in Lucene or Solr; though to be sure, it has been exercised extensively within Lucene’s test suite since inception. It’s hardy, just under-utilized outside custom expert-level coding to ensure index-time payloads are encoded the same way they are decoded at query time, and to hook this mechanism into scoring.

    In your case you probably want to flatten the document before indexing and indexing the value as separate tags, depending on what you want to do with the data.