전체 텍스트 검색을 사용하면 구조화된 필드에서 정확한 일치를 검색하는 대신 테이블을 검색하여 단어, 구문 또는 숫자를 찾을 수 있는 애플리케이션을 빌드할 수 있습니다. 전체 텍스트 검색은 트랜잭션에 일관성이 있는 최근에 커밋된 데이터를 애플리케이션에 반환합니다. Spanner 전체 텍스트 검색 기능에는 맞춤법 교정, 검색 입력의 언어 감지 자동화, 검색 결과 순위 지정이 포함됩니다.
Spanner는 대략적인 단어 일치를 포함하도록 텍스트 검색을 자동으로 확장합니다.
전체 텍스트 검색에 사용할 열에 검색 색인을 만들어야 합니다. Spanner는 이러한 열의 데이터를 분석하여 검색 색인에 추가할 개별 단어를 식별합니다.
Spanner는 데이터베이스에 데이터가 커밋되는 즉시 새 데이터 또는 수정된 데이터로 검색 색인을 업데이트합니다.
전체 텍스트 검색 유형
기본 텍스트 검색: 단어 또는 구문의 전체 또는 일부를 사용하여 콘텐츠를 검색하여 안정적으로 결과를 받습니다. 쿼리 조건자 예시:
모든 단어 일치 [tricolor rat terrier]
정확한 단어 또는 구문 ["rat terrier"]
다음 단어 중 하나 [miniature OR standard]
근접성이 가까운 단어 [world AROUND(3) cup]
하위 문자열 [start*]
숫자 검색: 숫자 동등성 및 비동등성 검색을 실행합니다.
동등성 검색은 일치하는 숫자를 검색합니다. 범위 및 비동등성 검색은 특정 범위 내의 숫자와 일치시킵니다.
N-그램 기반 검색: 고유 명사 및 이름을 비롯한 철자 변형이 있는 단어를 일치시킵니다. 이 유형의 검색은 쿼리 텍스트를 철자가 틀린 이름, 다른 철자가 사용된 이름, 다른 철자 변형이 사용된 텍스트와 일치시키는 데도 도움이 됩니다.
Soundex 검색: 발음이 비슷한 단어와 일치시킵니다.
전체 텍스트 검색 기능
Spanner 전체 텍스트 검색에는 다음과 같은 기능이 있습니다.
순위가 지정된 검색 결과: 쿼리가 문서와 얼마나 잘 일치하는지 측정하기 위한 점수를 계산합니다(예: column_A에 더 큰 가중치 부여). SQL 표현식을 사용하여 순위를 맞춤설정합니다.
스니펫: 검색결과에서 일치하는 텍스트를 강조 표시합니다.
전역 지원: CJK 세분화를 비롯한 다양한 언어의 토큰화를 자동으로 지원합니다. 언어를 수동으로 지정하면 추가 미세 조정을 수행할 수 있습니다.
거버넌스: 특정 단어와 일치하는 모든 항목을 찾습니다.
맞춤법 교정: 쿼리에서 맞춤법이 틀린 단어를 스토리지에 있는 올바른 맞춤법의 단어와 일치하도록 자동으로 수정합니다. 예를 들어 사용자가 'girafe'를 검색하면 'giraffe'가 포함된 문서가 검색됩니다.
문맥 동의어 추가(검색 제외 단어 포함): 문맥과 관련된 동의어를 자동으로 추가하여 재현율을 개선합니다. 예를 들어 'the house'는 'this house'와 일치시키고 'cat picture'는 'kitty picture'와 일치시킵니다.
텍스트를 사용하여 문맥에 맞는 숫자 변환: 숫자의 텍스트 버전을 숫자 표현과 일치시키고 그 반대로도 수행합니다. 예를 들어 'five cats'는 '5 cats'와 일치시킵니다.
자동 복수형 변환: 'cat'을 'cats'와 일치시킵니다.
전체 텍스트 검색 개념
전체 텍스트 검색에는 다음과 같은 주요 개념이 있습니다.
문서는 지정된 행의 검색 가능한 데이터를 나타냅니다.
토큰은 검색 색인에 저장된 문서의 각 단어를 나타냅니다.
토큰화 프로세스는 문서를 토큰으로 분할합니다.
토크나이저는 토큰화에 사용되는 SQL 함수입니다.
반전 색인은 토큰을 저장합니다. SQL 쿼리를 사용하여 반전 색인을 검색합니다.
전체 텍스트 검색 사용 사례 예시
전체 텍스트 검색을 이해하려면 데이터베이스를 사용하여 각 가수의 노래를 저장하는 애플리케이션을 살펴보겠습니다. 각 행은 한 개의 노래입니다. 각 노래에는 제목, 가사, 가수, 앨범과 같은 열이 포함됩니다. 이 애플리케이션은 전체 텍스트 검색을 사용하여 사용자가 자연어 쿼리를 사용하여 노래를 검색할 수 있도록 합니다.
검색은 Prince OR
Camille 같이 OR 연산자를 사용하는 쿼리를 지원합니다. 애플리케이션은 rquery 문법을 사용하여 검색창의 최종 사용자 입력을 SQL SEARCH 함수에 직접 제공할 수 있습니다. 자세한 내용은 검색 색인 쿼리를 참조하세요.
Spanner는 검색 색인을 사용하여 여러 필드에서 일치하는 문서를 찾습니다. 예를 들어 애플리케이션은 제목에 'cry', 가사에 'so cold', 가수에 'Prince'가 포함된 노래를 검색하는 쿼리를 실행할 수 있습니다.
검색 색인의 기타 용도
검색 색인은 전체 텍스트 검색 외에도 다음과 같은 다양한 용도로 사용할 수 있습니다.
배열 열의 요소 색인 생성 배열 열을 사용하여 항목과 연결된 태그를 저장하는 애플리케이션을 생각해 보세요. 검색 색인을 사용하면 애플리케이션에서 특정 태그가 포함된 행을 효율적으로 조회할 수 있습니다. 자세한 내용은 배열 토큰화를 참조하세요.
쿼리 조건 집합의 교집합에 있는 데이터를 찾습니다. 예를 들어 임의의 속성 집합(색상, 크기, 브랜드, 평점 등)을 사용하여 카탈로그에서 제품을 검색할 수 있습니다.
숫자 검색 조건을 단독으로 사용하거나 전체 텍스트 조건과 함께 사용합니다. 숫자 검색에 검색 색인이 유용한 경우의 예시는 다음과 같습니다.
전체 텍스트 애플리케이션과 결합되는 경우. 예를 들어 제목이 사진이고 크기가 1MB를 초과하는 이메일을 찾습니다.
앞에서 설명한 조건의 교집합에 포함되는 경우.
예를 들어 color = "yellow" AND size = 14 AND
rating >= 4.5인 제품을 찾습니다.
숫자 열의 교집합을 검색하는 경우. 예를 들어 이벤트 시작 시간과 종료 시간을 저장하는 테이블을 생각해 보세요. 검색 색인은 특정 시점(start_time <= @p AND
end_time > @p)에 발생한 이벤트를 찾는 쿼리를 효율적으로 구현할 수 있습니다.
[[["이해하기 쉬움","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-09-05(UTC)"],[],[],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)."]]