diff --git a/search_api.api.php b/search_api.api.php
index 4a9707c..3cebfb5 100644
--- a/search_api.api.php
+++ b/search_api.api.php
@@ -169,7 +169,7 @@ function hook_search_api_results_alter(\Drupal\search_api\Query\ResultSetInterfa
  *   Boolean indicating whether the index was also cleared.
  */
 function hook_search_api_index_reindex(\Drupal\search_api\IndexInterface $index, $clear = FALSE) {
-  db_insert('example_search_index_reindexed')
+  \Drupal\Core\Database\Database::getConnection()->insert('example_search_index_reindexed')
     ->fields(array(
       'index' => $index->id(),
       'clear' => $clear,
diff --git a/search_api_db/src/Plugin/search_api/backend/Database.php b/search_api_db/src/Plugin/search_api/backend/Database.php
index 538c20f..aa991c5 100644
--- a/search_api_db/src/Plugin/search_api/backend/Database.php
+++ b/search_api_db/src/Plugin/search_api/backend/Database.php
@@ -11,6 +11,7 @@ use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Database\Database as CoreDatabase;
+use Drupal\Core\Database\Query\Condition;
 use Drupal\Core\Database\Query\SelectInterface;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\Form\FormStateInterface;
@@ -1718,7 +1719,7 @@ class Database extends BackendPluginBase {
         }
       }
       else {
-        $or = db_or();
+        $or = new Condition('OR');
         foreach ($negated as $k) {
           $or->condition('t.item_id', $this->createKeysQuery($k, $fields, $all_fields, $index), 'NOT IN');
         }
@@ -1757,7 +1758,7 @@ class Database extends BackendPluginBase {
    *   Thrown if an unknown field was used in the filter.
    */
   protected function createFilterCondition(FilterInterface $filter, array $fields, SelectInterface $db_query, IndexInterface $index) {
-    $cond = db_condition($filter->getConjunction());
+    $cond =  new Condition($filter->getConjunction());
     $empty = TRUE;
     // Store whether a JOIN already occurred for a field, so we don't JOIN
     // repeatedly for OR filters.
@@ -1782,7 +1783,7 @@ class Database extends BackendPluginBase {
           // @todo Stop recognizing "!=" as an operator.
           $operator = ($f[2] == '<>' || $f[2] == '!=') ? 'NOT LIKE' : 'LIKE';
           $prefix = Utility::createCombinedId($f[1], '');
-          $cond->condition($alias . '.item_id', db_like($prefix) . '%', $operator);
+          $cond->condition($alias . '.item_id', $this->database->escapeLike($prefix) . '%', $operator);
           continue;
         }
         if (!isset($fields[$f[0]])) {
@@ -1893,7 +1894,7 @@ class Database extends BackendPluginBase {
 
       if (empty($facet['operator']) || $facet['operator'] != 'or') {
         // All the AND facets can use the main query.
-        $select = db_select($table, 't');
+        $select = $this->database->select($table, 't');
       }
       else {
         // For OR facets, we need to build a different base query that excludes
@@ -1907,7 +1908,7 @@ class Database extends BackendPluginBase {
           }
         }
         $or_db_query = $this->createDbQuery($or_query, $fields);
-        $select = db_select($or_db_query, 't');
+        $select = $this->database->select($or_db_query, 't');
       }
 
       // If "Include missing facet" is disabled, we use an INNER JOIN and add IS
diff --git a/search_api_db/src/Tests/BackendTest.php b/search_api_db/src/Tests/BackendTest.php
index a22f85d..4fd386f 100644
--- a/search_api_db/src/Tests/BackendTest.php
+++ b/search_api_db/src/Tests/BackendTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\search_api_db\Tests;
 
 use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Core\Database\Database;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
 use Drupal\field\Entity\FieldConfig;
@@ -814,7 +815,7 @@ class BackendTest extends EntityUnitTestBase {
     $results = $query->execute();
     $this->assertEqual($results->getResultCount(), 0, 'Clearing the server worked correctly.');
     $table = 'search_api_db_' . $this->indexId;
-    $this->assertTrue(db_table_exists($table), 'The index tables were left in place.');
+    $this->assertTrue(Database::getConnection()->schema()->tableExists($table), 'The index tables were left in place.');
 
     // Remove first the index and then the server.
     $index->setServer();
@@ -822,7 +823,7 @@ class BackendTest extends EntityUnitTestBase {
 
     $server = Server::load($this->serverId);
     $this->assertEqual($server->getBackendConfig()['field_tables'], array(), 'The index was successfully removed from the server.');
-    $this->assertFalse(db_table_exists($table), 'The index tables were deleted.');
+    $this->assertFalse(Database::getConnection()->schema()->tableExists($table), 'The index tables were deleted.');
     $server->delete();
 
     // Uninstall the module.
diff --git a/src/Plugin/search_api/processor/ContentAccess.php b/src/Plugin/search_api/processor/ContentAccess.php
index 977ec27..580f1b2 100644
--- a/src/Plugin/search_api/processor/ContentAccess.php
+++ b/src/Plugin/search_api/processor/ContentAccess.php
@@ -9,6 +9,7 @@ namespace Drupal\search_api\Plugin\search_api\processor;
 
 use Drupal\comment\CommentInterface;
 use Drupal\comment\Entity\Comment;
+use Drupal\Core\Database\Database;
 use Drupal\Core\Logger\LoggerChannelInterface;
 use Drupal\Core\Session\AccountInterface;
 use Drupal\Core\Session\AnonymousUserSession;
@@ -150,7 +151,7 @@ class ContentAccess extends ProcessorPluginBase {
       if (!$node->access('view', $anonymous_user)) {
         // If anonymous user has no permission we collect all grants with their
         // realms in the item.
-        $result = db_query('SELECT * FROM {node_access} WHERE (nid = 0 OR nid = :nid) AND grant_view = 1', array(':nid' => $node->id()));
+        $result = Database::getConnection()->query('SELECT * FROM {node_access} WHERE (nid = 0 OR nid = :nid) AND grant_view = 1', array(':nid' => $node->id()));
         foreach ($result as $grant) {
           $field->addValue("node_access_{$grant->realm}:{$grant->gid}");
         }
diff --git a/src/Plugin/views/filter/SearchApiTerm.php b/src/Plugin/views/filter/SearchApiTerm.php
index 10f7666..9841587 100644
--- a/src/Plugin/views/filter/SearchApiTerm.php
+++ b/src/Plugin/views/filter/SearchApiTerm.php
@@ -97,7 +97,7 @@ class SearchApiTerm extends SearchApiFilterEntityBase {
       }
       else {
         $options = array();
-        $query = db_select('taxonomy_term_data', 'td');
+        $query = Database::getConnection()->select('taxonomy_term_data', 'td');
         $query->innerJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
         $query->fields('td');
         $query->orderby('tv.weight');
@@ -255,7 +255,7 @@ class SearchApiTerm extends SearchApiFilterEntityBase {
       return array();
     }
 
-    $query = db_select('taxonomy_term_data', 'td');
+    $query = Database::getConnection()->select('taxonomy_term_data', 'td');
     $query->innerJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
     $query->fields('td');
     $query->condition('td.name', $names);
@@ -303,7 +303,7 @@ class SearchApiTerm extends SearchApiFilterEntityBase {
    * {@inheritdoc}
    */
   protected function idsToString(array $ids) {
-    return implode(', ', db_select('taxonomy_term_data', 'td')
+    return implode(', ', Database::getConnection()->select('taxonomy_term_data', 'td')
       ->fields('td', array('name'))
       ->condition('td.tid', array_filter($ids))
       ->execute()
diff --git a/src/Plugin/views/filter/SearchApiUser.php b/src/Plugin/views/filter/SearchApiUser.php
index 4a31aad..765c12f 100644
--- a/src/Plugin/views/filter/SearchApiUser.php
+++ b/src/Plugin/views/filter/SearchApiUser.php
@@ -8,6 +8,7 @@
 namespace Drupal\search_api\Plugin\views\filter;
 
 use Drupal\Component\Utility\Unicode;
+use Drupal\Core\Database\Database;
 use Drupal\Core\Form\FormStateInterface;
 
 /**
@@ -38,7 +39,7 @@ class SearchApiUser extends SearchApiFilterEntityBase {
   protected function idsToString(array $ids) {
     $names = array();
     $args[':uids'] = array_filter($ids);
-    $result = db_query("SELECT uid, name FROM {users} u WHERE uid IN (:uids)", $args);
+    $result = Database::getConnection()->query("SELECT uid, name FROM {users} u WHERE uid IN (:uids)", $args);
     $result = $result->fetchAllKeyed();
     foreach ($ids as $uid) {
       if (!$uid) {
@@ -70,7 +71,7 @@ class SearchApiUser extends SearchApiFilterEntityBase {
       return $uids;
     }
 
-    $result = db_query("SELECT * FROM {users} WHERE name IN (:names)", array(':names' => array_values($missing)));
+    $result = Database::getConnection()->query("SELECT * FROM {users} WHERE name IN (:names)", array(':names' => array_values($missing)));
     foreach ($result as $account) {
       unset($missing[strtolower($account->name)]);
       $uids[] = $account->uid;
diff --git a/src/Tests/Processor/ContentAccessTest.php b/src/Tests/Processor/ContentAccessTest.php
index e311a05..e2fc710 100644
--- a/src/Tests/Processor/ContentAccessTest.php
+++ b/src/Tests/Processor/ContentAccessTest.php
@@ -10,6 +10,7 @@ namespace Drupal\search_api\Tests\Processor;
 use Drupal\comment\Entity\Comment;
 use Drupal\comment\Entity\CommentType;
 use Drupal\comment\Tests\CommentTestTrait;
+use Drupal\Core\Database\Database;
 use Drupal\node\Entity\Node;
 use Drupal\node\Entity\NodeType;
 use Drupal\search_api\Query\ResultSetInterface;
@@ -165,7 +166,7 @@ class ContentAccessTest extends ProcessorTestBase {
     // Create user that will be passed into the query.
     $authenticated_user = $this->createUser(array('uid' => 2), array('access content'));
 
-    db_insert('node_access')
+    Database::getConnection()->insert('node_access')
       ->fields(array(
         'nid' => $this->nodes[0]->id(),
         'langcode' => $this->nodes[0]->language()->getId(),
