diff --git a/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/ContextQuery.java b/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/ContextQuery.java
index 467708a272..c52df14489 100644
--- a/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/ContextQuery.java
+++ b/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/ContextQuery.java
@@ -34,6 +34,8 @@ import org.apache.lucene.util.automaton.Automaton;
 import org.apache.lucene.util.automaton.Operations;
 import org.apache.lucene.util.fst.Util;
 
+import static org.apache.lucene.search.suggest.document.CompletionAnalyzer.DEFAULT_PRESERVE_SEP;
+
 /**
  * A {@link CompletionQuery} that matches documents specified by
  * a wrapped {@link CompletionQuery} supporting boosting and/or filtering
@@ -80,21 +82,36 @@ public class ContextQuery extends CompletionQuery {
   private boolean matchAllContexts = false;
   /** Inner completion query */
   protected CompletionQuery innerQuery;
+  private final boolean preserveSep;
 
   /**
    * Constructs a context completion query that matches
    * documents specified by <code>query</code>.
    * <p>
    * Use {@link #addContext(CharSequence, float, boolean)}
-   * to add context(s) with boost
+   * to add context(s) with boost.
    */
   public ContextQuery(CompletionQuery query) {
+    this(query, DEFAULT_PRESERVE_SEP);
+  }
+
+  /**
+   * Constructs a context completion query that matches
+   * documents specified by <code>query</code>.
+   * <code>preserveSep</code> must match the value used to
+   * index the suggestions: {@link CompletionAnalyzer#preserveSep}.
+   * <p>
+   * Use {@link #addContext(CharSequence, float, boolean)}
+   * to add context(s) with boost.
+   */
+  public ContextQuery(CompletionQuery query, boolean preserveSep) {
     super(query.getTerm(), query.getFilter());
     if (query instanceof ContextQuery) {
       throw new IllegalArgumentException("'query' parameter must not be of type "
               + this.getClass().getSimpleName());
     }
     this.innerQuery = query;
+    this.preserveSep = preserveSep;
     contexts = new HashMap<>();
   }
 
@@ -167,11 +184,13 @@ public class ContextQuery extends CompletionQuery {
   @Override
   public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException {
     final CompletionWeight innerWeight = ((CompletionWeight) innerQuery.createWeight(searcher, scoreMode, boost));
-    // if separators are preserved the fst contains a SEP_LABEL
-    // behind each gap. To have a matching automaton, we need to
-    // include the SEP_LABEL in the query as well
-    Automaton optionalSepLabel = Operations.optional(Automata.makeChar(CompletionAnalyzer.SEP_LABEL));
-    Automaton prefixAutomaton = Operations.concatenate(optionalSepLabel, innerWeight.getAutomaton());
+    Automaton prefixAutomaton = innerWeight.getAutomaton();
+    if (preserveSep) {
+      // if separators are preserved the fst contains a SEP_LABEL
+      // behind each gap. To have a matching automaton, we need to
+      // include the SEP_LABEL in the query as well
+      prefixAutomaton = Operations.concatenate(Automata.makeChar(CompletionAnalyzer.SEP_LABEL), innerWeight.getAutomaton());
+    }
     Automaton contextsAutomaton = Operations.concatenate(toContextAutomaton(contexts, matchAllContexts), prefixAutomaton);
     contextsAutomaton = Operations.determinize(contextsAutomaton, Operations.DEFAULT_MAX_DETERMINIZED_STATES);
 
diff --git a/lucene/suggest/src/test/org/apache/lucene/search/suggest/document/TestContextQuery.java b/lucene/suggest/src/test/org/apache/lucene/search/suggest/document/TestContextQuery.java
index 2c5dcd8e54..3be336143b 100644
--- a/lucene/suggest/src/test/org/apache/lucene/search/suggest/document/TestContextQuery.java
+++ b/lucene/suggest/src/test/org/apache/lucene/search/suggest/document/TestContextQuery.java
@@ -16,6 +16,7 @@
  */
 package org.apache.lucene.search.suggest.document;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Comparator;
@@ -37,6 +38,7 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.apache.lucene.search.suggest.document.CompletionAnalyzer.DEFAULT_MAX_GRAPH_EXPANSIONS;
 import static org.apache.lucene.search.suggest.document.TestSuggestField.Entry;
 import static org.apache.lucene.search.suggest.document.TestSuggestField.assertSuggestions;
 import static org.apache.lucene.search.suggest.document.TestSuggestField.iwcWithSuggestField;
@@ -525,4 +527,53 @@ public class TestContextQuery extends LuceneTestCase {
       }
     }
   }
+
+  @Test
+  public void testRegexDotQueryPreserveSep() throws Exception {
+    assertRegexpDotCase(true);
+  }
+
+  @Test
+  public void testRegexDotQuery() throws Exception {
+    assertRegexpDotCase(false);
+  }
+
+  private void assertRegexpDotCase(boolean preserveSep) throws IOException {
+    Analyzer analyzer = new MockAnalyzer(random());
+    analyzer = new CompletionAnalyzer(analyzer, preserveSep, preserveSep, DEFAULT_MAX_GRAPH_EXPANSIONS);
+
+    RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwcWithSuggestField(analyzer, "suggest_field"));
+    Document document = new Document();
+    document.add(new ContextSuggestField("suggest_field", "suggestion1", 1, "type"));
+    document.add(new ContextSuggestField("suggest_field", "uggestion1", 1, "type"));
+    document.add(new ContextSuggestField("suggest_field", "suggestion2", 2, "type"));
+    iw.addDocument(document);
+
+    DirectoryReader reader = iw.getReader();
+    SuggestIndexSearcher suggestIndexSearcher = new SuggestIndexSearcher(reader);
+
+    {
+      ContextQuery query = new ContextQuery(new RegexCompletionQuery(new Term("suggest_field", ".")), preserveSep);
+      query.addContext("type", 1);
+
+      TopSuggestDocs suggest = suggestIndexSearcher.suggest(query, 4, false);
+      assertSuggestions(suggest,
+          new Entry("suggestion2", "type", 2),
+          new Entry("uggestion1", "type", 1),
+          new Entry("suggestion1", "type", 1));
+    }
+
+    {
+      ContextQuery query = new ContextQuery(new RegexCompletionQuery(new Term("suggest_field", ".u")), preserveSep);
+      query.addContext("type", 1);
+
+      TopSuggestDocs suggest = suggestIndexSearcher.suggest(query, 4, false);
+      assertSuggestions(suggest,
+          new Entry("suggestion2", "type", 2),
+          new Entry("suggestion1", "type", 1));
+    }
+
+    reader.close();
+    iw.close();
+  }
 }
