Определение синонимов

Organizations often have unique terminology or multiple ways to refer to the same concept. Defining synonyms establishes term equivalency, helping users find items during searches.

Define synonyms by indexing items with the _dictionaryEntry well-known schema.

Items of type _dictionaryEntry can have the following properties:

Свойство Тип Описание Необходимый?
_term string The term to define. Recommended values are unhyphenated words or phrases without punctuation. Необходимый
_synonym string (repeated) Alternate terms to be included in queries matching the string defined in _term . Необходимый
_onlyApplicableForAttachedSearchApplications boolean Allows you to group synonyms by data source and search application. For further information, see Define data source-specific synonyms . Необязательный

Когда пользователь включает значение _term в запрос, фактический запрос становится " term OR synonyms ". Например, если вы определяете "scifi" с помощью синонима "science fiction" , запрос для "scifi" будет соответствовать элементам, содержащим любой из этих терминов.

Синонимы по умолчанию не являются двунаправленными. Запрос по слову "science fiction" будет соответствовать только этой точной фразе, если вы не определите её как термин, в котором "scifi" является синонимом. Чтобы сделать термины взаимозаменяемыми, определите каждый из них отдельно:

Срок Синонимы
scifi science fiction
science fiction scifi

При обработке запроса удаляются дефисы и знаки препинания перед применением синонимов. Запрос по слову "sci-fi" соответствует термину "sci fi" . Для поддержки терминов с дефисами, нормализуйте _term , используя пробелы вместо дефисов.

Взаимозаменяемые примеры:

Срок Синонимы
scifi science fiction, sci fi
sci fi science fiction, scifi
science fiction scifi, sci fi

By default, synonyms apply across the entire domain and all search applications. To limit them, see Define data source-specific synonyms .

Определяйте глобальные синонимы с помощью SDK.

Use the Content Connector SDK to define terms and synonyms. See Create a content connector for details.

This snippet builds a RepositoryDoc from a CSV record:

DictionaryConnector.java
/**
 * 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
 */
private ApiOperation buildDocument(CSVRecord record) {
  // Extract term and synonyms from record
  String term = 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);
  }

  String itemName = String.format("dictionary/%s", term);

  // Using the SDK item builder class to create the item
  Item item =
      IndexingItemBuilder.fromConfiguration(itemName)
          .setItemType(IndexingItemBuilder.ItemType.CONTENT_ITEM)
          .setObjectType("_dictionaryEntry")
          .setValues(structuredData)
          .setAcl(DOMAIN_PUBLIC_ACL)
          .build();

  // Create the fully formed document
  return new RepositoryDoc.Builder()
      .setItem(item)
      .build();
}

Важные замечания:

  • Synonym entries must be domain public. For example, you can set the ACL to DOMAIN_PUBLIC_ACL .
  • Avoid settings in your configuration file that override this, such as defaultAcl.mode=FALLBACK or defaultAcl.public=true .

Определите синонимы, специфичные для конкретного поискового приложения.

Чтобы предоставить синонимы, специфичные для каждой команды (например, для инженерного отдела и отдела продаж), проиндексируйте каждый синоним с помощью _onlyApplicableForAttachedSearchApplications=true . Это ограничит поиск синонимами только теми приложениями, которые содержат конкретный источник данных.

Пример:

structuredData.put("_onlyApplicableForAttachedSearchApplications", true);