**MatchingTermsLookupFactory**:
```lang=php
public function getLookupForDatabase( $dbName ): MatchingTermsLookup {
$loadBalancer = $this->loadBalancerFactory->getMainLB( $dbName );
$databaseTypeIdsStore = new DatabaseTypeIdsStore(
$loadBalancer,
$this->objectCache,
$dbName,
$this->logger
);
return new DatabaseMatchingTermsLookup(
$loadBalancer,
$databaseTypeIdsStore,
$databaseTypeIdsStore,
$this->entityIdComposer,
$this->logger
);
}
```
DatabaseTypeIdsStore creates a `NameTableStore` which uses the LoadBalancer as follows:
```lang=php
private function getDBConnection( $index, $flags = 0 ) {
return $this->loadBalancer->getConnectionRef( $index, [], $this->domain, $flags );
}
```
and
```lang=php
$this->loadBalancer->resolveDomainID( $this->domain )
```
`DatabaseMatchingTermsLookup` uses it only to get a connection:
```lang=php
private function getDbr() {
return $this->lb->getConnection( ILoadBalancer::DB_REPLICA, [], $this->databaseDomain );
}
```