diff --git a/src/Lunr/Gravity/Database/DMLQueryBuilderInterface.php b/src/Lunr/Gravity/Database/DMLQueryBuilderInterface.php
index ca041927ce2ba5ec86cf947c033ce8829faa5d6b..e1045b328a17614419e097f996455a2062848ac0 100644
--- a/src/Lunr/Gravity/Database/DMLQueryBuilderInterface.php
+++ b/src/Lunr/Gravity/Database/DMLQueryBuilderInterface.php
@@ -443,11 +443,11 @@ interface DMLQueryBuilderInterface
      * Define a UNION or UNION ALL clause of the SQL statement.
      *
      * @param string $sql_query SQL query reference
-     * @param bool   $all       True for ALL or False for empty (default).
+     * @param string $type      Type of UNION operation to perform.
      *
      * @return DMLQueryBuilderInterface $self Self reference
      */
-    public function union($sql_query, $all = FALSE);
+    public function union($sql_query, $type);
 
     /**
      * Define the lock mode for a transaction.
diff --git a/src/Lunr/Gravity/Database/DatabaseDMLQueryBuilder.php b/src/Lunr/Gravity/Database/DatabaseDMLQueryBuilder.php
index 621fa1a63924c86be87d70d1877aad9107e93fec..3a9c8062f64993e523b5ebd62734b172c81bb54c 100644
--- a/src/Lunr/Gravity/Database/DatabaseDMLQueryBuilder.php
+++ b/src/Lunr/Gravity/Database/DatabaseDMLQueryBuilder.php
@@ -808,18 +808,26 @@ abstract class DatabaseDMLQueryBuilder implements DMLQueryBuilderInterface
      * Define a compound clause for the SQL statement.
      *
      * @param string $sql_query Left expression
-     * @param string $base      Whether to construct UNION, EXCEPT or INTERSECT
+     * @param string $type      Whether to construct UNION, EXCEPT or INTERSECT
+     * @param mixed  $operator  Whether to add ALL, DISTINCT or default
      *
      * @return void
      */
-    protected function sql_compound($sql_query, $base)
+    protected function sql_compound($sql_query, $type, $operator = NULL)
     {
         if ($this->compound != '')
         {
             $this->compound .= ' ';
         }
+        if($operator == 'ALL' || $operator == 'DISTINCT' || empty($operator))
+        {
+            $base = $type . " " . $operator;
+        }
+        else{
+            $base = $type;
+        }
 
-        $this->compound .= $base . ' ' . $sql_query;
+        $this->compound .= rtrim($base) . ' ' . $sql_query;
     }
 
     /**
diff --git a/src/Lunr/Gravity/Database/MySQL/MySQLSimpleDMLQueryBuilder.php b/src/Lunr/Gravity/Database/MySQL/MySQLSimpleDMLQueryBuilder.php
index 4d2faca639ee137b3cf9b46213c2b5024c937a81..c9f1f1ce41f1bcb8e783a6d3da758ec9e42d4520 100644
--- a/src/Lunr/Gravity/Database/MySQL/MySQLSimpleDMLQueryBuilder.php
+++ b/src/Lunr/Gravity/Database/MySQL/MySQLSimpleDMLQueryBuilder.php
@@ -782,13 +782,13 @@ class MySQLSimpleDMLQueryBuilder implements DMLQueryBuilderInterface
      * Define a UNION or UNION ALL clause of the SQL statement.
      *
      * @param string $sql_query SQL query reference
-     * @param bool   $all       True for ALL or False for empty (default).
+     * @param string $type      Type of UNION operation to perform.
      *
      * @return MySQLSimpleDMLQueryBuilder $self Self reference
      */
-    public function union($sql_query, $all = FALSE)
+    public function union($sql_query, $type = NULL)
     {
-        $this->builder->union($this->escaper->query_value($sql_query), $all);
+        $this->builder->union($this->escaper->query_value($sql_query), $type);
         return $this;
     }
 
diff --git a/src/Lunr/Gravity/Database/MySQL/Tests/MySQLSimpleDMLQueryBuilderSelectTest.php b/src/Lunr/Gravity/Database/MySQL/Tests/MySQLSimpleDMLQueryBuilderSelectTest.php
index 7cf20eda8677702090279357ddc98389e3cf23dc..caf71456e15c2871e639ca8d42c6cc9c79b10bcf 100644
--- a/src/Lunr/Gravity/Database/MySQL/Tests/MySQLSimpleDMLQueryBuilderSelectTest.php
+++ b/src/Lunr/Gravity/Database/MySQL/Tests/MySQLSimpleDMLQueryBuilderSelectTest.php
@@ -200,17 +200,37 @@ class MySQLSimpleDMLQueryBuilderSelectTest extends MySQLSimpleDMLQueryBuilderTes
     {
         $this->escaper->expects($this->once())
                       ->method('query_value')
-                      ->with($this->equalTo('query'))
-                      ->will($this->returnValue('(query)'));
+                      ->with('query')
+                      ->willReturn('(query)');
 
         $this->builder->expects($this->once())
                       ->method('union')
-                      ->with($this->equalTo('(query)'))
-                      ->will($this->returnSelf());
+                      ->with('(query)')
+                      ->willReturnSelf();
 
         $this->class->union('query');
     }
 
+    /**
+     * Test union() distinct.
+     *
+     * @covers Lunr\Gravity\Database\MySQL\MySQLSimpleDMLQueryBuilder::union
+     */
+    public function testUnionDistinct(): void
+    {
+        $this->escaper->expects($this->once())
+                      ->method('query_value')
+                      ->with('query')
+                      ->willReturn('(query)');
+
+        $this->builder->expects($this->once())
+                      ->method('union')
+                      ->with('(query)', 'DISTINCT')
+                      ->willReturnSelf();
+
+        $this->class->union('query', 'DISTINCT');
+    }
+
      /**
      * Test union() all.
      *
@@ -220,17 +240,57 @@ class MySQLSimpleDMLQueryBuilderSelectTest extends MySQLSimpleDMLQueryBuilderTes
     {
         $this->escaper->expects($this->once())
                       ->method('query_value')
-                      ->with($this->equalTo('query'))
-                      ->will($this->returnValue('(query)'));
+                      ->with('query')
+                      ->willReturn('(query)');
 
         $this->builder->expects($this->once())
                       ->method('union')
-                      ->with($this->equalTo('(query)', TRUE), $this->equalTo(TRUE))
-                      ->will($this->returnSelf());
+                      ->with('(query)', 'ALL')
+                      ->willReturnSelf();
+
+        $this->class->union('query', 'ALL');
+    }
+
+    /**
+     * Test union() when parameter passed is TRUE.
+     *
+     * @covers Lunr\Gravity\Database\MySQL\MySQLSimpleDMLQueryBuilder::union
+     */
+    public function testUnionWithTypeTrue(): void
+    {
+        $this->escaper->expects($this->once())
+                      ->method('query_value')
+                      ->with('query')
+                      ->willReturn('(query)');
+
+        $this->builder->expects($this->once())
+                      ->method('union')
+                      ->with('(query)', TRUE)
+                      ->willReturnSelf();
 
         $this->class->union('query', TRUE);
     }
 
+    /**
+     * Test union() when parameter passed is FALSE.
+     *
+     * @covers Lunr\Gravity\Database\MySQL\MySQLSimpleDMLQueryBuilder::union
+     */
+    public function testUnionWithTypeFalse(): void
+    {
+        $this->escaper->expects($this->once())
+                      ->method('query_value')
+                      ->with('query')
+                      ->willReturn('(query)');
+
+        $this->builder->expects($this->once())
+                      ->method('union')
+                      ->with('(query)', FALSE)
+                      ->willReturnSelf();
+
+        $this->class->union('query', FALSE);
+    }
+
 }
 
 ?>
diff --git a/src/Lunr/Gravity/Database/SQLDMLQueryBuilder.php b/src/Lunr/Gravity/Database/SQLDMLQueryBuilder.php
index 8598aa54e5c2ce0a3cb656a454372ce48dee62b1..df6913a85513764c9431aa2de3ceec5e9f89918d 100644
--- a/src/Lunr/Gravity/Database/SQLDMLQueryBuilder.php
+++ b/src/Lunr/Gravity/Database/SQLDMLQueryBuilder.php
@@ -517,17 +517,16 @@ abstract class SQLDMLQueryBuilder extends DatabaseDMLQueryBuilder
     }
 
     /**
-     * Define a UNION or UNION ALL clause of the SQL statement.
-     *
-     * @param string $sql_query SQL query reference
-     * @param bool   $all       True for ALL or False for empty (default).
-     *
-     * @return SQLDMLQueryBuilder $self Self reference
-     */
-    public function union($sql_query, $all = FALSE)
-    {
-        $base = ($all === TRUE) ? 'UNION ALL' : 'UNION';
-        $this->sql_compound($sql_query, $base);
+    * Define a UNION, UNION DISTINCT or UNION ALL clause of the SQL statement.
+    *
+    * @param string $sql_query SQL query reference
+    * @param string $operator  UNION operation to perform
+    *
+    * @return SQLDMLQueryBuilder $self Self reference
+    */
+    public function union($sql_query, $operator = NULL)
+    {
+        $this->sql_compound($sql_query, 'UNION', strtoupper($operator));
         return $this;
     }
 
diff --git a/src/Lunr/Gravity/Database/Tests/DatabaseDMLQueryBuilderQueryPartsTest.php b/src/Lunr/Gravity/Database/Tests/DatabaseDMLQueryBuilderQueryPartsTest.php
index 1dcb661843034cf2d9f4547dde12868cd36bdbeb..380c040646bade691337dba7e17fd8c956b1bd71 100644
--- a/src/Lunr/Gravity/Database/Tests/DatabaseDMLQueryBuilderQueryPartsTest.php
+++ b/src/Lunr/Gravity/Database/Tests/DatabaseDMLQueryBuilderQueryPartsTest.php
@@ -25,7 +25,7 @@ class DatabaseDMLQueryBuilderQueryPartsTest extends DatabaseDMLQueryBuilderTest
     /**
      * Test specifying the UNION part of a query.
      *
-     * @param string $types Compound query operator
+     * @param string $types     Compound query operator
      *
      * @dataProvider compoundQueryTypeProvider
      * @covers       Lunr\Gravity\Database\DatabaseDMLQueryBuilder::sql_compound
diff --git a/src/Lunr/Gravity/Database/Tests/DatabaseDMLQueryBuilderTest.php b/src/Lunr/Gravity/Database/Tests/DatabaseDMLQueryBuilderTest.php
index b180e22ed1ac5bebe7b6d0260d1637b987cecfb6..402702a68b10428a87d48cd04522c75ea6574029 100644
--- a/src/Lunr/Gravity/Database/Tests/DatabaseDMLQueryBuilderTest.php
+++ b/src/Lunr/Gravity/Database/Tests/DatabaseDMLQueryBuilderTest.php
@@ -119,8 +119,13 @@ abstract class DatabaseDMLQueryBuilderTest extends LunrBaseTest
         $types   = [];
         $types[] = [ 'UNION' ];
         $types[] = [ 'UNION ALL' ];
+        $types[] = [ 'UNION DISTINCT' ];
         $types[] = [ 'EXCEPT' ];
+        $types[] = [ 'EXCEPT ALL' ];
+        $types[] = [ 'EXCEPT DISTINCT' ];
         $types[] = [ 'INTERSECT' ];
+        $types[] = [ 'INTERSECT ALL' ];
+        $types[] = [ 'INTERSECT DISTINCT' ];
 
         return $types;
     }
diff --git a/src/Lunr/Gravity/Database/Tests/SQLDMLQueryBuilderSelectTest.php b/src/Lunr/Gravity/Database/Tests/SQLDMLQueryBuilderSelectTest.php
index b6986b6c0adb48bc0cc0de6a8b7532b14b4e8ded..0bbeca299ef30cf02f3b506aa480d0e6b5ead5db 100644
--- a/src/Lunr/Gravity/Database/Tests/SQLDMLQueryBuilderSelectTest.php
+++ b/src/Lunr/Gravity/Database/Tests/SQLDMLQueryBuilderSelectTest.php
@@ -176,6 +176,19 @@ class SQLDMLQueryBuilderSelectTest extends SQLDMLQueryBuilderTest
         $this->assertPropertyEquals('compound', 'UNION QUERY');
     }
 
+    /**
+     * Test specifying a UNION DISTINCT statement.
+     *
+     * @depends Lunr\Gravity\Database\Tests\DatabaseDMLQueryBuilderQueryPartsTest::testCompoundQuery
+     * @covers  Lunr\Gravity\Database\SQLDMLQueryBuilder::union
+     */
+    public function testUnionDistinct(): void
+    {
+        $return = $this->class->union('QUERY', 'DISTINCT');
+
+        $this->assertPropertyEquals('compound', 'UNION DISTINCT QUERY');
+    }
+
     /**
      * Test specifying a UNION ALL statement.
      *
@@ -184,7 +197,7 @@ class SQLDMLQueryBuilderSelectTest extends SQLDMLQueryBuilderTest
      */
     public function testUnionAll(): void
     {
-        $return = $this->class->union('QUERY', TRUE);
+        $return = $this->class->union('QUERY', 'ALL');
 
         $this->assertPropertyEquals('compound', 'UNION ALL QUERY');
     }
