You will get an iterator for each doc, each containing only the payloads for this document. There is actually no way to get all payloads for all documents at the same time.
Here is an example:
DELETE testidx
PUT testidx
{
"mappings": {
"doc": {
"properties": {
"categories": {
"type": "string",
"analyzer": "payload"
}
}
}
},
"settings": {
"analysis": {
"analyzer": {
"payload": {
"type": "custom",
"tokenizer": "keyword",
"filter": [
"delimited_payload_filter"
]
}
}
}
}
}
POST testidx/doc/
{
"id": 1,
"categories": ["1000|0.1","1001|0.2"]
}
POST testidx/doc/
{
"id": 2,
"categories": ["1000|0.2","1001|0.2"]
}
POST testidx/doc/
{
"id": 3,
"categories": ["1000|0.3","1001|0.2"]
}
GET testidx/doc/_search
{
"fields": [
"_source"
],
"script_fields": {
"payloads": {
"script": "payloads = []; positions = _index['categories'].get('1000', _PAYLOADS); for(pos in positions){payloads.add(pos.payloadAsFloat(0))}; payloads"
}
}
}
yields:
"hits": {
"total": 3,
"max_score": 1,
"hits": [
{
"_index": "testidx",
"_type": "doc",
"_id": "AU-sK5gxjoOwWjOATroI",
"_score": 1,
"_source": {
"id": 3,
"categories": [
"1000|0.3",
"1001|0.2"
]
},
"fields": {
"payloads": [
[
0.3
]
]
}
},
{
"_index": "testidx",
"_type": "doc",
"_id": "AU-sJk0KjoOwWjOATrk2",
"_score": 1,
"_source": {
"id": 1,
"categories": [
"1000|0.1",
"1001|0.2"
]
},
"fields": {
"payloads": [
[
0.1
]
]
}
},
{
"_index": "testidx",
"_type": "doc",
"_id": "AU-sK6BajoOwWjOATroJ",
"_score": 1,
"_source": {
"id": 2,
"categories": [
"1000|0.2",
"1001|0.2"
]
},
"fields": {
"payloads": [
[
0.2
]
]
}
}
]
}