[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-11 (世界標準時間)。"],[],[],null,["# Full-text search overview\n\n| **Note:** This feature is available with the Spanner Enterprise edition and Enterprise Plus edition. For more information, see the [Spanner editions overview](/spanner/docs/editions-overview).\n\n\u003cbr /\u003e\n\nThis page describes what full-text search is and how it works.\n\nA full-text search lets you build an application that can search a table to find\nwords, phrases, or numbers, instead of just searching for exact matches in\nstructured fields. Full-text searches return the latest\ntransactionally-consistent committed data to your application. Spanner\nfull-text search capabilities also include making spelling corrections,\nautomating language detection of search input, and ranking search results.\nSpanner automatically expands text searches to include\napproximate word matching.\n\nYou need to create a search index on any columns that you want to make available\nfor full-text searches. Spanner analyzes the\ndata in those columns to identify individual words to add to the search index.\nSpanner updates the search index with new or modified data as soon as\nit's committed in the database.\n\nTypes of full-text search\n-------------------------\n\n- **Basic text search** : Searches for content using the entire or part of a word or phrase to reliably receive results. Example query predicates:\n - Matching all words \\[tricolor rat terrier\\]\n - Exact word or phrases \\[\"rat terrier\"\\]\n - Any of these words \\[miniature OR standard\\]\n - Word within close proximity \\[world AROUND(3) cup\\]\n - Substring \\[start\\*\\]\n- **Numeric search**: Performs numeric equality and inequality searches. Equality searches match a number. Range and inequality searches match a number within a specific range.\n- **n-gram-based search**: Matches words with spelling variations, including proper nouns and names. This type of search also helps to match query text with misspelled names, names with alternate spellings, and text with other spelling variations.\n- **Soundex searches**: Matches similar-sounding words.\n\nFull-text search features\n-------------------------\n\nSpanner full-text search has the following features:\n\n- **Ranked search results**: Computes a score to gauge how well a query matches a document (for example, giving a heavier weight for column_A). Use SQL expressions to customize ranking.\n- **Snippets**: Highlights the matching text in the search result.\n- **Global support** : Automatically supports tokenization in different languages, including [CJK](https://en.wikipedia.org/wiki/CJK_characters) segmentation. Manual specification of language lets you perform additional fine-tuning.\n- **Governance**: Finds every occurrence of specific words.\n- **Spelling correction**: Automatically corrects misspelled words in queries to match the correctly-spelled word in storage. For example, if the user searches for \"girafe\", the search finds documents with \"giraffe\".\n- **Contextual synonym addition, including stop words**: Automatically adds contextually-relevant synonyms to increase recall. For example, \"the house\" matches \"this house\" and \"cat picture\" matches \"kitty picture\".\n- **Contextual number translation to and from text**: Matches the textual version of a number to the numeric representation and vice-versa. For example, \"five cats\" matches \"5 cats\".\n- **Automatic plural conversion**: Matches \"cat\" to \"cats\".\n\nFull-text search concepts\n-------------------------\n\nFull-text search has the following key concepts:\n\n- A *document* refers to the searchable data in a given row.\n- A *token* refers to each word of a document that's stored in a search index.\n- A *tokenization* process splits a document into tokens.\n- A *tokenizer* is a SQL function used for tokenization.\n- An *inverted index* stores tokens. Use SQL queries to search the inverted index.\n\nUse case example for full-text search\n-------------------------------------\n\nTo understand full-text search, let's take a look at an application that\nuses a database to store songs for each singer. Each row is a single song. Each\nsong contains columns like title, lyrics, singer, and album. The application\nuses full-text search to let a user search for a song using natural language\nqueries:\n\n- The search supports queries that use the `OR` operator, like `Prince OR\n Camille`. Applications can directly feed the end user input from the search box into the SQL [`SEARCH`](/spanner/docs/full-text-search/query-overview#query_a_search_index) function (using the rquery syntax). For more information, see [Query a\n search\n index](/spanner/docs/full-text-search/query-overview#query_a_search_index).\n- Spanner uses search indexes to look for matching documents across different fields. For example, an application can issue a query to search for \"cry\" in the title, with \"so cold\" in the lyrics, and \"Prince\" as the singer.\n\nOther uses for search indexes\n-----------------------------\n\nSearch indexes have a variety of uses in addition to full-text search, such as\nthe following:\n\n- Indexing elements in array columns. Consider an application that uses an\n array column to store tags associated with an item. With search indexes, the\n application can efficiently look up rows containing a specific tag. For more\n information, see\n [Array tokenization](/spanner/docs/full-text-search/numeric-indexes#array-tokenization).\n\n \u003cbr /\u003e\n\n- Finding data that resides in the intersection of a set\n of query conditions. For example, you can use an arbitrary set of attributes\n (color, size, brand, rating, and so on) to search for a product in a\n catalog.\n\n- Using numeric search conditions, alone or in combination with full-text\n conditions. Some examples for when a search index is useful for numeric\n searches:\n\n - When it's combined with a full-text application. For example, to find an email with the subject **Picture** and size greater than 1 MB.\n - When it's part of an intersection of conditions described previously. For example, to find products where `color = \"yellow\" AND size = 14 AND\n rating \u003e= 4.5`.\n - When searching for the intersection of numeric columns. For example, consider a table storing event start and end times. Search indexes can efficiently implement a query that looks for events that took place at a particular point in time: `start_time \u003c= @p AND\n end_time \u003e @p`.\n\n For more information, see\n [Numeric indexes](/spanner/docs/full-text-search/numeric-indexes).\n\nFull-text search steps\n----------------------\n\nIn Spanner, full-text search requires the following steps:\n\n1. Tokenize a document using the Spanner tokenizer functions, such as [`TOKENIZE_SUBSTRING`](/spanner/docs/reference/standard-sql/search_functions#tokenize_substring). For more information, see [Tokenization](/spanner/docs/full-text-search/tokenization).\n2. Create a search index to hold the tokens using the [`CREATE SEARCH\n INDEX`](/spanner/docs/reference/standard-sql/data-definition-language#create-search-index) DDL statement. For more information, see [Search\n indexes](/spanner/docs/full-text-search/search-indexes).\n3. Query documents in the search index using the Spanner [`SEARCH`](/spanner/docs/reference/standard-sql/search_functions#search_fulltext) function. For more information, see [Query\n overview](/spanner/docs/full-text-search/query-overview).\n4. Rank the results of the query using the Spanner [`SCORE`](/spanner/docs/reference/standard-sql/search_functions#score) function. For more information, see [Rank search\n results](/spanner/docs/full-text-search/ranked-search).\n\nLimitations\n-----------\n\n- Full-text search doesn't support [Assured Workloads](/assured-workloads/docs/overview).\n\nPricing\n-------\n\nThere are no additional charges from Spanner when you use\nfull-text search, although the implementation of full-text search\nincreases costs due to the need for additional compute and storage resources.\n\nFor more information, see [Spanner pricing](/spanner/pricing).\n\nWhat's next\n-----------\n\n- Learn about [tokenization and Spanner tokenizers](/spanner/docs/full-text-search/tokenization).\n- Learn about [search indexes](/spanner/docs/full-text-search/search-indexes).\n- Learn about [full-text search queries](/spanner/docs/full-text-search/query-overview)."]]