Add local table name to a matching row

I have a configuration like this:

table index1 {
    type = plain
    path = ...
}
table index2 {
    type = plain
    path = ...
}
table main {
    type = distributed
    local = index1
    local = index2
}

when I make a select from main, is there a way to tell which result comes from which index? Like

select bar, MAGIC() FROM main
| bar   | MAGIC  |
+---------------------
| 11    | index1 |
| 22    | index2 |
| 33    | index1 |
| 44    | index1 |
| 55    | index2 |

Dont think so.

But can probably create a virtual attribute that does this

Typically quote easy with plain indexes, as can hardcoded in the ‘source’ for each index.

source src1 {
   ....
   sql_query = SELECT id, title, 1 as idx FROM table ...
   sql_attr_uint = idx:4

source src2 {
   ....
   sql_query = SELECT id, title, 2 as idx FROM table ...
   sql_attr_uint = idx:4

Query is easy :slight_smile:

select bar, idx FROM main

index id \ tag does used internally but does not get exposed into result set for now. You have to add attribute and use it if you need index name for every document.