同义词

class elasticsearch.client.SynonymsClient

To use this client, access client.synonyms from an Elasticsearch client. For example:

from elasticsearch import Elasticsearch

# Create the client instance
client = Elasticsearch(...)
# Use the synonyms client
client.synonyms.<method>(...)
delete_synonym(*, id, error_trace=None, filter_path=None, human=None, pretty=None)

删除同义词集。

只能删除未被任何索引分析器使用的同义词集。

同义词集可用于同义词图标记过滤器和同义词标记过滤器。 这些同义词过滤器可作为搜索分析器的一部分使用。

分析器需要在索引恢复时加载(例如节点启动或索引变为打开状态时)。 即使分析器未在任何字段映射中使用,仍需要在索引恢复阶段加载。

如果任何分析器无法加载,索引将变为不可用状态,且集群状态会因索引分片不可用而变为红色或黄色。 为防止这种情况,分析器中使用的同义词集不能被删除。 此类情况下的删除请求将返回400响应码。

要移除同义词集,必须先删除所有包含使用该同义词集的分析器的索引。 可通过创建不包含该同义词集标记过滤器的新索引,并使用reindex API复制索引数据来完成迁移。 完成后即可删除原索引。 当同义词集不再被分析器使用时,即可将其删除。

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-synonyms-delete-synonym

Parameters:
  • id (str) – 要删除的同义词集标识符。

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

Return type:

ObjectApiResponse[Any]

delete_synonym_rule(*, set_id, rule_id, error_trace=None, filter_path=None, human=None, pretty=None, refresh=None)

删除同义词规则。 从同义词集中删除一条同义词规则。

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-synonyms-delete-synonym-rule

Parameters:
  • set_id (str) – 要更新的同义词集ID。

  • rule_id (str) – 要删除的同义词规则ID。

  • refresh (bool | None) – 若为`true`,请求将在返回前刷新使用被删除同义词规则的分析器,并等待新同义词生效。 若为`false`,分析器将不会重新加载被删除的同义词规则。

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

Return type:

ObjectApiResponse[Any]

get_synonym(*, id, error_trace=None, filter_path=None, from_=None, human=None, pretty=None, size=None)

获取同义词集。

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-synonyms-get-synonym

Parameters:
  • id (str) – 要检索的同义词集标识符。

  • from – 要检索的同义词规则的起始偏移量。

  • size (int | None) – 要检索的同义词规则的最大数量。

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • from_ (int | None)

  • human (bool | None)

  • pretty (bool | None)

Return type:

ObjectApiResponse[Any]

get_synonym_rule(*, set_id, rule_id, error_trace=None, filter_path=None, human=None, pretty=None)

获取同义词规则。 从同义词集中获取一条同义词规则。

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-synonyms-get-synonym-rule

Parameters:
  • set_id (str) – 要从中检索同义词规则的同义词集ID。

  • rule_id (str) – 要检索的同义词规则ID。

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

Return type:

ObjectApiResponse[Any]

get_synonyms_sets(*, error_trace=None, filter_path=None, from_=None, human=None, pretty=None, size=None)

获取所有同义词集。 获取所有已定义同义词集的摘要信息。

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-synonyms-get-synonym

Parameters:
  • from – 要检索的同义词集的起始偏移量。

  • size (int | None) – 要检索的同义词集的最大数量。

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • from_ (int | None)

  • human (bool | None)

  • pretty (bool | None)

Return type:

ObjectApiResponse[Any]

put_synonym(*, id, synonyms_set=None, error_trace=None, filter_path=None, human=None, pretty=None, refresh=None, body=None)

创建或更新同义词集。 每个同义词集最多可包含10,000条同义词规则。 如需管理更多同义词规则,可创建多个同义词集。

更新现有同义词集时,所有使用该同义词集的搜索分析器将自动重新加载。 这等同于对所有使用该同义词集的索引调用重新加载搜索分析器API。

关于如何创建或更新同义词集的实际示例,请参阅外部文档。

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-synonyms-put-synonym

Parameters:
  • id (str) – 要创建或更新的同义词集ID。

  • synonyms_set (Mapping[str, Any] | Sequence[Mapping[str, Any]] | None) – 同义词集的同义词规则定义。

  • refresh (bool | None) – 若为`true`,请求将在返回前刷新分析器并等待新同义词生效。 若为`false`,分析器不会重新加载新同义词集

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

  • body (Dict[str, Any] | None)

Return type:

ObjectApiResponse[Any]

put_synonym_rule(*, set_id, rule_id, synonyms=None, error_trace=None, filter_path=None, human=None, pretty=None, refresh=None, body=None)

创建或更新同义词规则。 在同义词集中创建或更新同义词规则。

若包含无效的同义词规则,API将返回错误。

更新同义词规则时,所有使用该同义词集的分析器将自动重新加载以应用新规则。

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-synonyms-put-synonym-rule

Parameters:
  • set_id (str) – 同义词集ID。

  • rule_id (str) – 要更新或创建的同义词规则ID。

  • synonyms (str | None) – 同义词规则信息定义,必须采用Solr格式。

  • refresh (bool | None) – 若为`true`,请求将在返回前刷新分析器并等待新同义词生效。 若为`false`,分析器不会重新加载新同义词规则

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

  • body (Dict[str, Any] | None)

Return type:

ObjectApiResponse[Any]