조직은 일반적으로 개념이나 사물을 지칭하는 고유한 용어나 여러 가지 방법을 사용합니다. 사용자가 원하는 항목을 검색하는 데 도움이 되도록 용어의 유사성을 정립하는 동의어를 정의해야 합니다.
동의어는 _dictionaryEntry라는 잘 알려진 스키마를 사용하여 항목의 색인을 생성하는 방식으로 정의합니다.
_dictionaryEntry 유형의 항목에는 다음 속성이 있을 수 있습니다.
속성
유형
설명
필수 여부
_term
string
정의할 용어. 권장 값은 구두점과 하이픈이 없는 단어 또는 구입니다.
필수
_synonym
string (repeated)
_term에 정의된 문자열과 일치하며, 쿼리에 포함되는 대체 용어
필수
_onlyApplicableForAttachedSearchApplications
boolean
데이터 소스 및 검색 애플리케이션별로 동의어를 그룹화할 수 있습니다. 자세한 내용은 데이터 소스별 동의어 정의를 참고하세요.
선택사항
사용자가 쿼리에 _term 속성 값을 포함하면 유효한 쿼리가 'term OR synonyms'이 됩니다. 예를 들어 "scifi"이라는 용어가 "science fiction"이라는 동의어로 정의된 경우 "scifi"이라는 단어가 포함된 쿼리는 "scifi" 또는 "science fiction."이 포함된 항목과 일치합니다.
동의어는 양방향으로 적용되지 않습니다. 대신에 "science fiction,"에 대한 쿼리에는 동의어가 적용되지 않습니다. 이 쿼리는 "science fiction."이 포함된 항목하고만 일치합니다. "scifi"이 포함된 항목은 생략됩니다.
두 용어를 서로 바꿔서 사용할 수 있게 하려면 각 용어를 별도로 정의하세요.
용어
동의어
scifi
science fiction
science fiction
scifi
쿼리 처리 중에는 하이픈 및 기타 구두점이 제거된 후 동의어가 적용됩니다. 사용자 쿼리가 _term과 일치합니다. "sci fi." 사용자가 하이픈을 추가할 수 있는 용어의 동의어를 만들려면 먼저 하이픈 대신 공백을 사용하도록 _term을 정규화하세요."sci-fi"
위의 예에서 다음과 같은 정의는 "sci-fi," "sci fi," "scifi,"과 "science fiction"을 서로 바꿔서 사용할 수 있는 용어로 처리하는 사용자 쿼리와 일치합니다.
용어
동의어
scifi
science fiction, sci fi
sci fi
science fiction, scifi
science fiction
scifi, sci fi
기본적으로 모든 데이터 소스의 동의어는 전체 도메인에 적용됩니다.
특히 동의어는 데이터 소스에 관계없이 모든 검색의 검색 애플리케이션에 적용됩니다. 데이터 소스별 동의어가 필요한 경우 데이터 소스별 동의어 정의를 참고하세요.
Cloud Search SDK를 사용하여 전역 동의어 정의
콘텐츠 커넥터 SDK를 사용하여 용어와 동의어를 정의할 수 있습니다. 커넥터 제작 방법을 보려면 콘텐츠 커넥터 만들기를 참조하세요.
다음 스니펫은 CSV 파일 레코드를 기반으로 용어와 동의어를 표현하는 RepositoryDoc를 만드는 방법을 보여줍니다.
/** * Creates a document for indexing. * * For this connector sample, the created document is domain public * searchable. The content is a simple text string. * * @param record The current CSV record to convert * @return the fully formed document ready for indexing */privateApiOperationbuildDocument(CSVRecordrecord){// Extract term and synonyms from recordStringterm=record.get(0);List<String>synonyms=StreamSupport.stream(record.spliterator(),false).skip(1)// Skip term.collect(Collectors.toList());Multimap<String,Object>structuredData=ArrayListMultimap.create();structuredData.put("_term",term);structuredData.putAll("_synonym",synonyms);if(Configuration.getBoolean("dictionary.attachedToSearchApp",false).get()){structuredData.put("_onlyApplicableForAttachedSearchApplications",true);}StringitemName=String.format("dictionary/%s",term);// Using the SDK item builder class to create the itemItemitem=IndexingItemBuilder.fromConfiguration(itemName).setItemType(IndexingItemBuilder.ItemType.CONTENT_ITEM).setObjectType("_dictionaryEntry").setValues(structuredData).setAcl(DOMAIN_PUBLIC_ACL).build();// Create the fully formed documentreturnnewRepositoryDoc.Builder().setItem(item).build();}
동의어를 정의할 때는 다음 사항에 유의하세요.
동의어 항목은 도메인 공용이어야 합니다. 이전 예에서는 ACL을 DOMAIN_PUBLIC_ACL로 설정하면 이를 구현할 수 있습니다.
다음 속성은 코드의 도메인 공개 설정을 재정의하므로 구성 파일에 정의되어서는 안 됩니다.
defaultAcl.mode=FALLBACK
defaultAcl.public=true
검색 애플리케이션별 동의어 정의
기본적으로 동의어는 모든 검색 애플리케이션의 모든 데이터 소스에 적용됩니다.
하지만 조직에 엔지니어링팀과 영업팀이 별도로 있고 직무별 동의어를 포함하여 각 팀에 서로 다른 검색 환경을 제공하려는 경우를 가정해 보겠습니다. 이 경우 엔지니어링 관련 데이터 소스와 동의어가 있는 검색 애플리케이션과 영업 관련 데이터 소스와 동의어가 있는 검색 애플리케이션을 각각 만들 수 있습니다. 이 목표를 달성하려면 _onlyApplicableForAttachedSearchApplications=true를 사용하여 특정 데이터 소스의 각 동의어를 색인화합니다. 이 설정은 특정 데이터 소스를 포함하는 검색 애플리케이션에만 동의어가 적용되도록 동의어를 제한합니다.
예를 들어 이전 코드 샘플에 다음 코드 줄을 추가하면 색인이 생성된 동의어가 데이터 소스에만 적용됩니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-29(UTC)"],[],[],null,["# Define synonyms\n\nIt's common for an organization to have unique terminology or multiple ways\nto refer to a concept or thing. You should define synonyms to establish\nequivalency of terms to helps users find items when searching.\n| **Note:** Custom synonyms can only be defined for third-party data sources; they can't be defined for Google Workspace data sources, such as Google Drive or Gmail.\n\nSynonyms are defined by indexing items with the `_dictionaryEntry` well-known\nschema.\n\nItems of type `_dictionaryEntry` can have the following properties:\n\n| Property | Type | Description | Required? |\n|------------------------------------------------|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|\n| `_term` | string | The term to define. Recommended values are unhyphenated words or phrases without punctuation. | Required |\n| `_synonym` | string (repeated) | Alternate terms to be included in queries matching the string defined in `_term`. | Required |\n| `_onlyApplicableForAttachedSearchApplications` | boolean | Allows you to group synonyms by data source and search application. For further information, see [Define data source-specific synonyms](/workspace/cloud-search/docs/guides/synonyms#specific). | Optional |\n\n| **Note:** Items indexed with `_dictionaryEntry` schema don't count towards the data source limits in a search application.\n\nWhen a user includes the value of the `_term` property in a query,\nthe *effective* query becomes \"*term OR synonyms* .\" For example, if the\nterm \"scifi\" is defined with the synonym\n\"science fiction\" then a query\ncontaining the word \"scifi\" matches items containing\neither \"scifi\"\nor \"science fiction.\"\n\nSynonyms are not applied bidirectionally. If the query is instead for\n\"science fiction,\" Cloud Search\ndoesn't apply any synonyms to the query. The query only matches items containing\n\"science fiction.\" Items containing\n\"scifi\" are omitted.\n\nTo make all both terms interchangeable, define each term separately:\n\n| Term | Synonyms |\n|-----------------|-----------------|\n| scifi | science fiction |\n| science fiction | scifi |\n\nDuring query processing, hyphenation and other punctuation are removed prior\nto applying synonyms. The user query \"sci-fi\"\nmatches the `_term` \"sci fi.\"\nTo create synonyms for terms which may be hyphenated by users, first normalize\nthe `_term` to use whitespace instead of hyphens.\n\nContinuing the example, the following definitions match the user queries treat\n\"sci-fi,\" \"sci fi,\" \"scifi,\" and\n\"science fiction\" as interchangeable:\n\n| Term | Synonyms |\n|-----------------|-------------------------|\n| scifi | science fiction, sci fi |\n| sci fi | science fiction, scifi |\n| science fiction | scifi, sci fi |\n\n| **Note:** It may take up to 5 hours before synonyms are processed and are used to rewrite queries.\n\nBy default, synonyms in any data source apply across an entire domain.\nSpecifically, synonyms are applied across search applications for all searches\nregardless of the data source. If you want data source-specific synonyms, refer\nto [Define data source-specific synonyms](#specific).\n\nDefine global synonyms using the Cloud Search SDK\n-------------------------------------------------\n\nYou can use the Content Connector SDK to define terms and their synonyms. See\n[Create a content connector](/workspace/cloud-search/docs/guides/content-connector) for\ninstructions on building a connector.\n\nThe following snippet illustrates building a\n[`RepositoryDoc`](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/indexing/template/RepositoryDoc)\nrepresenting the term and synonym based on a CSV file record: \nDictionaryConnector.java \n[View on GitHub](https://github.com/googleworkspace/cloud-search-samples/blob/main/indexing/connector/sdk/dictionary-connector/src/main/java/com/google/cloudsearch/samples/DictionaryConnector.java) \n\n```java\n/**\n * Creates a document for indexing.\n *\n * For this connector sample, the created document is domain public\n * searchable. The content is a simple text string.\n *\n * @param record The current CSV record to convert\n * @return the fully formed document ready for indexing\n */\nprivate ApiOperation buildDocument(CSVRecord record) {\n // Extract term and synonyms from record\n String term = record.get(0);\n List\u003cString\u003e synonyms = StreamSupport.stream(record.spliterator(), false)\n .skip(1) // Skip term\n .collect(Collectors.toList());\n\n Multimap\u003cString, Object\u003e structuredData = ArrayListMultimap.create();\n structuredData.put(\"_term\", term);\n structuredData.putAll(\"_synonym\", synonyms);\n\n if (Configuration.getBoolean(\"dictionary.attachedToSearchApp\", false).get()) {\n structuredData.put(\"_onlyApplicableForAttachedSearchApplications\", true);\n }\n\n String itemName = String.format(\"dictionary/%s\", term);\n\n // Using the SDK item builder class to create the item\n Item item =\n IndexingItemBuilder.fromConfiguration(itemName)\n .setItemType(IndexingItemBuilder.ItemType.CONTENT_ITEM)\n .setObjectType(\"_dictionaryEntry\")\n .setValues(structuredData)\n .setAcl(DOMAIN_PUBLIC_ACL)\n .build();\n\n // Create the fully formed document\n return new RepositoryDoc.Builder()\n .setItem(item)\n .build();\n}\n```\n\nNote the following when defining synonyms:\n\n- Synonym entries are required to be domain public. In the previous example, this is accomplished by setting the ACL to `DOMAIN_PUBLIC_ACL`.\n- The following properties should not be defined for your configuration file because they override the domain public setting in your code:\n - `defaultAcl.mode=FALLBACK`\n - `defaultAcl.public=true`\n\nDefine search application-specific synonyms\n-------------------------------------------\n\nBy default, synonyms are applied to all data sources across all search\napplications.\n\nHowever, suppose your organization has separate engineering and sales teams, and\nyou want to provide each team with a different search experience, including\njob role-specific synonyms. In this case, you could create one search\napplication with an engineering-specific data source and synonyms and another\nsearch application with a sales-specific data source and synonyms. To accomplish\nthis goal, index each synonym in a specific data source\nusing `_onlyApplicableForAttachedSearchApplications=true`. This\nsetting limits the synonyms such that they are only applied to search\napplications that include a specific data source.\n\nFor example, adding the\nfollowing line of code to the previous code sample ensures the indexed synonyms\nare data source-specific: \n\n structuredData.put(\"_onlyApplicableForAttachedSearchApplications\", true);"]]