diff --git a/src/backend/access/gin/ginget.c b/src/backend/access/gin/ginget.c
index 03191e016ce..8be0191e147 100644
--- a/src/backend/access/gin/ginget.c
+++ b/src/backend/access/gin/ginget.c
@@ -1232,11 +1232,14 @@ keyGetItem(GinState *ginstate, MemoryContext tempCtx, GinScanKey key,
 
 	res = key->triConsistentFn(key);
 
+	/*
+	 * Convert the ternary result value into a boolean with recheck flag
+	 */
 	switch (res)
 	{
 		case GIN_TRUE:
 			key->curItemMatches = true;
-			/* triConsistentFn set recheckCurItem */
+			key->recheckCurItem = false;
 			break;
 
 		case GIN_FALSE:
@@ -1888,13 +1891,22 @@ scanPendingInsert(IndexScanDesc scan, TIDBitmap *tbm, int64 *ntids)
 		for (i = 0; i < so->nkeys; i++)
 		{
 			GinScanKey	key = so->keys + i;
+			GinTernaryValue res;
 
-			if (!key->boolConsistentFn(key))
+			res = key->boolConsistentFn(key);
+			if (res == GIN_TRUE)
+				continue;
+			else if (res == GIN_FALSE)
 			{
 				match = false;
 				break;
 			}
-			recheck |= key->recheckCurItem;
+			else
+			{
+				Assert(res == GIN_MAYBE);
+				recheck = true;
+				continue;
+			}
 		}
 
 		MemoryContextSwitchTo(oldCtx);
diff --git a/src/backend/access/gin/ginlogic.c b/src/backend/access/gin/ginlogic.c
index 6bf3288f5b9..f15208d7718 100644
--- a/src/backend/access/gin/ginlogic.c
+++ b/src/backend/access/gin/ginlogic.c
@@ -50,16 +50,10 @@
 #define MAX_MAYBE_ENTRIES	4
 
 /*
- * Dummy consistent functions for an EVERYTHING key.  Just claim it matches.
+ * Dummy consistent function for an EVERYTHING key.  Just claim it matches.
  */
-static bool
-trueConsistentFn(GinScanKey key)
-{
-	key->recheckCurItem = false;
-	return true;
-}
 static GinTernaryValue
-trueTriConsistentFn(GinScanKey key)
+trueConsistentFn(GinScanKey key)
 {
 	return GIN_TRUE;
 }
@@ -67,25 +61,36 @@ trueTriConsistentFn(GinScanKey key)
 /*
  * A helper function for calling a regular, binary logic, consistent function.
  */
-static bool
+static GinTernaryValue
 directBoolConsistentFn(GinScanKey key)
 {
+	bool		boolResult;
+
 	/*
 	 * Initialize recheckCurItem in case the consistentFn doesn't know it
 	 * should set it.  The safe assumption in that case is to force recheck.
 	 */
 	key->recheckCurItem = true;
-
-	return DatumGetBool(FunctionCall8Coll(key->consistentFmgrInfo,
-										  key->collation,
-										  PointerGetDatum(key->entryRes),
-										  UInt16GetDatum(key->strategy),
-										  key->query,
-										  UInt32GetDatum(key->nuserentries),
-										  PointerGetDatum(key->extra_data),
-										  PointerGetDatum(&key->recheckCurItem),
-										  PointerGetDatum(key->queryValues),
-										  PointerGetDatum(key->queryCategories)));
+	boolResult = DatumGetBool(FunctionCall8Coll(key->consistentFmgrInfo,
+												key->collation,
+												PointerGetDatum(key->entryRes),
+												UInt16GetDatum(key->strategy),
+												key->query,
+												UInt32GetDatum(key->nuserentries),
+												PointerGetDatum(key->extra_data),
+												PointerGetDatum(&key->recheckCurItem),
+												PointerGetDatum(key->queryValues),
+												PointerGetDatum(key->queryCategories)));
+	if (boolResult)
+	{
+		/* TRUE with recheck is taken to mean MAYBE */
+		if (key->recheckCurItem)
+			return GIN_MAYBE;
+		else
+			return GIN_TRUE;
+	}
+	else
+		return GIN_FALSE;
 }
 
 /*
@@ -110,12 +115,10 @@ directTriConsistentFn(GinScanKey key)
  * logic consistent function provided by the opclass. GIN_MAYBE return value
  * is interpreted as true with recheck flag.
  */
-static bool
+static GinTernaryValue
 shimBoolConsistentFn(GinScanKey key)
 {
-	GinTernaryValue result;
-
-	result = DatumGetGinTernaryValue(FunctionCall7Coll(key->triConsistentFmgrInfo,
+	return DatumGetGinTernaryValue(FunctionCall7Coll(key->triConsistentFmgrInfo,
 													   key->collation,
 													   PointerGetDatum(key->entryRes),
 													   UInt16GetDatum(key->strategy),
@@ -124,16 +127,6 @@ shimBoolConsistentFn(GinScanKey key)
 													   PointerGetDatum(key->extra_data),
 													   PointerGetDatum(key->queryValues),
 													   PointerGetDatum(key->queryCategories)));
-	if (result == GIN_MAYBE)
-	{
-		key->recheckCurItem = true;
-		return true;
-	}
-	else
-	{
-		key->recheckCurItem = false;
-		return result;
-	}
 }
 
 /*
@@ -153,9 +146,8 @@ shimTriConsistentFn(GinScanKey key)
 {
 	int			nmaybe;
 	int			maybeEntries[MAX_MAYBE_ENTRIES];
+	int			ntrue;
 	int			i;
-	bool		boolResult;
-	bool		recheck = false;
 	GinTernaryValue curResult;
 
 	/*
@@ -164,6 +156,7 @@ shimTriConsistentFn(GinScanKey key)
 	 * test all combinations, so give up and return MAYBE.
 	 */
 	nmaybe = 0;
+	ntrue = 0;
 	for (i = 0; i < key->nentries; i++)
 	{
 		if (key->entryRes[i] == GIN_MAYBE)
@@ -172,22 +165,41 @@ shimTriConsistentFn(GinScanKey key)
 				return GIN_MAYBE;
 			maybeEntries[nmaybe++] = i;
 		}
+		if (key->entryRes[i] == GIN_TRUE)
+			ntrue++;
 	}
 
 	/*
-	 * If none of the inputs were MAYBE, so we can just call consistent
+	 * If none of the inputs were MAYBE, we can just call the consistent
 	 * function as is.
 	 */
 	if (nmaybe == 0)
 		return directBoolConsistentFn(key);
 
-	/* First call consistent function with all the maybe-inputs set FALSE */
-	for (i = 0; i < nmaybe; i++)
-		key->entryRes[maybeEntries[i]] = GIN_FALSE;
+	/*
+	 * Make the first call to the consistent function. In the default search mode,
+	 * be careful to not call it with all-FALSE input.
+	 */
+	if (key->searchMode == GIN_SEARCH_MODE_DEFAULT && ntrue == 0)
+	{
+		key->entryRes[maybeEntries[0]] = GIN_TRUE;
+		for (i = 1; i < nmaybe; i++)
+			key->entryRes[maybeEntries[i]] = GIN_FALSE;
+	}
+	else
+	{
+		for (i = 0; i < nmaybe; i++)
+			key->entryRes[maybeEntries[i]] = GIN_FALSE;
+	}
+
 	curResult = directBoolConsistentFn(key);
+	if (curResult == GIN_MAYBE)
+		return GIN_MAYBE;
 
 	for (;;)
 	{
+		GinTernaryValue thisResult;
+
 		/* Twiddle the entries for next combination. */
 		for (i = 0; i < nmaybe; i++)
 		{
@@ -202,17 +214,11 @@ shimTriConsistentFn(GinScanKey key)
 		if (i == nmaybe)
 			break;
 
-		boolResult = directBoolConsistentFn(key);
-		recheck |= key->recheckCurItem;
-
-		if (curResult != boolResult)
+		thisResult = directBoolConsistentFn(key);
+		if (thisResult != curResult)
 			return GIN_MAYBE;
 	}
 
-	/* TRUE with recheck is taken to mean MAYBE */
-	if (curResult == GIN_TRUE && recheck)
-		curResult = GIN_MAYBE;
-
 	return curResult;
 }
 
@@ -225,7 +231,7 @@ ginInitConsistentFunction(GinState *ginstate, GinScanKey key)
 	if (key->searchMode == GIN_SEARCH_MODE_EVERYTHING)
 	{
 		key->boolConsistentFn = trueConsistentFn;
-		key->triConsistentFn = trueTriConsistentFn;
+		key->triConsistentFn = trueConsistentFn;
 	}
 	else
 	{
diff --git a/src/include/access/gin_private.h b/src/include/access/gin_private.h
index 670a40b4bee..eb8261822d7 100644
--- a/src/include/access/gin_private.h
+++ b/src/include/access/gin_private.h
@@ -288,7 +288,7 @@ typedef struct GinScanKeyData
 
 	/* array of check flags, reported to consistentFn */
 	GinTernaryValue *entryRes;
-	bool		(*boolConsistentFn) (GinScanKey key);
+	GinTernaryValue (*boolConsistentFn) (GinScanKey key);
 	GinTernaryValue (*triConsistentFn) (GinScanKey key);
 	FmgrInfo   *consistentFmgrInfo;
 	FmgrInfo   *triConsistentFmgrInfo;
