internal/postgres/symbolsearch: remove support for matching on field and method names

Symbol search on an exact symbol names that matches on field or method
names is too slow, so support is removed until performance can be
improved.

The cause is because too many symbol ids will be returned (for example,
3 rows on a exact match for "db", vs 5.2K+ when also matching on field
and method names).

For golang/go#44142

Change-Id: Ie59b376a84ea0344a4c40c804b28324d32594e72
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/341670
Trust: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/internal/postgres/symbolsearch/query.gen.go b/internal/postgres/symbolsearch/query.gen.go
index da10984..b360aab 100644
--- a/internal/postgres/symbolsearch/query.gen.go
+++ b/internal/postgres/symbolsearch/query.gen.go
@@ -185,7 +185,7 @@
 const queryMatchingSymbolIDsSymbol = `
 		SELECT id
 		FROM symbol_names
-		WHERE tsv_name_tokens @@ to_tsquery('symbols', quote_literal(replace($1, '_', '-'))) OR lower(name) = lower($1)`
+		WHERE lower(name) = lower($1)`
 
 // queryMatchingSymbolIDsPackageDotSymbol is used to find the matching symbol
 // ids when the SearchType is SearchTypePackageDotSymbol.
@@ -206,4 +206,4 @@
 const queryMatchingSymbolIDsMultiWordExact = `
 		SELECT id
 		FROM symbol_names
-		WHERE tsv_name_tokens @@ to_tsquery('symbols', quote_literal(replace($1, '_', '-'))) OR lower(name) = lower($1)`
+		WHERE lower(name) = lower($1)`
diff --git a/internal/postgres/symbolsearch/symbolsearch.go b/internal/postgres/symbolsearch/symbolsearch.go
index 08d086d..5a428c3 100644
--- a/internal/postgres/symbolsearch/symbolsearch.go
+++ b/internal/postgres/symbolsearch/symbolsearch.go
@@ -115,13 +115,13 @@
 	switch st {
 	case SearchTypeSymbol, SearchTypeMultiWordExact:
 		// When $1 is the full symbol name, either <symbol> or
-		// <type>.<methodOrField>, match on both the identifier name
-		// and just the field or method name.
-		// For example, "Begin" will return "DB.Begin".
+		// <type>.<methodOrField>, match on just the identifier name.
 		//
-		// tsv_name_tokens does a bad job of indexing symbol names with
-		// multiple "_", so also do an exact match search.
-		filter = fmt.Sprintf(`tsv_name_tokens @@ %s OR lower(name) = lower($1)`, toTSQuery("$1"))
+		// Matching on just <field> and <method> is too slow at the moment (can
+		// take several seconds to return results), but we
+		// might want to add support for that later. For example, searching for
+		// "Begin" should return "DB.Begin".
+		filter = `lower(name) = lower($1)`
 	case SearchTypePackageDotSymbol:
 		// When $1 is either <package>.<symbol> OR
 		// <package>.<type>.<methodOrField>, only match on the exact
diff --git a/internal/postgres/symbolsearch_test.go b/internal/postgres/symbolsearch_test.go
index 7777a2a..0eb9004 100644
--- a/internal/postgres/symbolsearch_test.go
+++ b/internal/postgres/symbolsearch_test.go
@@ -55,11 +55,15 @@
 			q:    sample.Variable.Name,
 			want: checkResult(sample.Variable.SymbolMeta),
 		},
-		{
-			name: "test search by <methodName>",
-			q:    "Method",
-			want: checkResult(sample.Method),
-		},
+		/*
+			TODO(golang/go#44142): Add support for searching just by field or
+			method name.
+			{
+				name: "test search by <methodName>",
+				q:    "Method",
+				want: checkResult(sample.Method),
+			},
+		*/
 		{
 			name: "test search by <package>.<type>.<methodName>",
 			q:    "foo.Type.Method",
diff --git a/tests/search/scripts/symbolsearch.txt b/tests/search/scripts/symbolsearch.txt
index df912f6..7d206a4 100644
--- a/tests/search/scripts/symbolsearch.txt
+++ b/tests/search/scripts/symbolsearch.txt
@@ -13,10 +13,6 @@
 
 Prefer symbols by popularity, then alphabetically, Add
 Add
-Float.Add math/big
-Int.Add math/big
-Rat.Add math/big
-Registry.Add github.com/go-openapi/strfmt
 Add math/bits
 
 Prefer symbols by package path, then symbol name
@@ -31,21 +27,15 @@
 Writer compress/zlib
 Writer encoding/csv
 Writer io
-Logger.Writer log
 Writer log
 
 Search for package path element and symbol.
 math Add
-Float.Add math/big
-Int.Add math/big
-Rat.Add math/big
 Add math/bits
 
 Search for package path element with slash and symbol.
-math/big Add
-Float.Add math/big
-Int.Add math/big
-Rat.Add math/big
+math/big Float
+Float math/big
 
 Search for <package path>.<symbol>.
 math/big.Float