To allow searches to be performed on a foreign repo via direct DB access, we need TermSqlIndex to be aware not only of the DB name, but also of the repo name. This is needed to construct EntityIds with the correct repo prefix to be used in the TermIndexEntry objects returned by TermSqlIndex.
Implementation note: TermIndexEntry is currently bound closely to the actual table structure, and there is no obvious way to supply the repo name here. The problem is rooted in the fact that the terms table uses numeric entity IDs. Some refactoring may be needed to make this work nicely.