Yes. Sorry for a somewhat obtuse reply.
This is similar to the coding scheme we use for the Indexed DB implementation in Chromium on top of LevelDB. Different types of data (records, indexes, etc) are given different key prefixes, but all data for e.g. one origin is stored in a single leveldb instance. That's what I was intending to evoke with the "type_index" and "type_record" prefixes.
For each record (i.e. unique primary key) you have an entry in the index table. For example, say you're storing these records (and ignoring type prefixes for the moment):
<aaa, bbb, ccc> = data:xxx
<ddd, bbb, eee> = data:yyy
<fff, ggg, eee> = data:zzz
Then you'd want these entries for an index on substr2:
<bbb, aaa, bbb, ccc> = sentinel
<bbb, ddd, bbb, eee> = sentinel
<ggg, fff, ggg, eee> = sentinel
Then to find all of the records that have substr2 = bbb you look for the index entries with the prefix bbb. The suffix of the key is the primary key of the record, which gets you back to the data. This also assumes you're not simply concatenating bits together, but have a string terminator or strings are length-prefixed.
(I'm not sure if your use of substr is intended to be *any* arbitrary substring of the key, or if you really have three-part keys. I've been assuming the latter.)
The sentinel is a small dummy value for a record, which isn't actually used. You only need the key itself, which gives you the primary key. IIRC, the sentinel can be the empty string.