多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# Text ## 简述 该字段用于索引全文文本,例如电子邮件的正文或产品的描述。 对这些字段进行`analyzed` ,即通过[分析器](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis.html&usg=ALkJrhirN7jhwydyE_LAqx9sWSrWroJIEw "分析")将其转换成索引之前的各个术语列表。 分析过程允许Elasticsearch搜索每个全文本字段中的单个单词。 文本字段不用于排序,很少用于聚合(尽管[重要的术语聚合](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html)是一个显着的例外)。 如果您需要索引结构化内容(如电子邮件地址,主机名,状态代码或标签),则可能您应该使用[`keyword`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html&usg=ALkJrhhyUd1xPy5C3s0WRAvmcIZEdkdTog "关键字数据类型")字段。 对于代码或标签,您也可能应该使用[`keyword`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html&usg=ALkJrhhyUd1xPy5C3s0WRAvmcIZEdkdTog "关键字数据类型")字段。 ## 示例 以下是文本字段的映射示例: | `PUT my_index` `{` `"mappings"``: {` `"my_type"``: {` `"properties"``: {` `"full_name"``: {` `"type"``:  ``"text"` `}` `}` `}` `}` `}` | 有时,同时具有全文( `text` )和关键字( `keyword` )版本是有帮助的:一个用于全文本搜索,另一个用于聚合和排序。 这可以通过多字段实现。 ## 参数 `text`字段接受以下参数: | [`analyzer`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/analyzer.html&usg=ALkJrhjWYcEqRqAnSdiBQHby7_zK46-Dpw "分析仪") | [分析器](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis.html&usg=ALkJrhirN7jhwydyE_LAqx9sWSrWroJIEw "分析")应用于[`analyzed`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-index.html&usg=ALkJrhjDd2JjTHxFwTWIVGOI0jtRnFerSQ "指数")字符串字段,无论是在索引时间还是在搜索时间(除非被[`search_analyzer`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/search-analyzer.html&usg=ALkJrhjlUDDK1IODYLamOAaDkDghyQMDdg "search_analyzer") )。 默认为默认索引分析器或[`standard`分析器](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-standard-analyzer.html&usg=ALkJrhgnaMsuZ8BjMzcdTPsqtO7AIaLIMw "标准分析仪")。 | | [`boost`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-boost.html&usg=ALkJrhgVxuBoIuXlpit73lN4jkPWykZGvQ "促进") | 映射字段级查询时间提升。 接受一个浮点数,默认为`1.0` 。 | | [`eager_global_ordinals`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html&usg=ALkJrhh444VidGXZXd5bc6TTbow62TkW8A#global-ordinals "全球序数") | 是否应该全新加载全局序号? `true`或`false` (默认)。 对于经常用于(重要)术语聚合的字段,启用此功能是一个好主意。 | | [`fielddata`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html&usg=ALkJrhh444VidGXZXd5bc6TTbow62TkW8A "fielddata") | 是否可以使用内存中的字段数据进行排序,聚合或脚本编写? `true`或`false` (默认)。 | | [`fielddata_frequency_filter`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html&usg=ALkJrhh444VidGXZXd5bc6TTbow62TkW8A#field-data-filtering "fielddata_frequency_filter") | 此为高级设置,允许在`fielddata`启用时决定哪些值加载到内存中。 默认情况下,所有值都被加载。 | | [`fields`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html&usg=ALkJrhhcdnrgkkNQb_bKmdXsZM0KxinNCg "领域") | 多字段允许以多种方式将相同的字符串值索引到不同的目的,例如用于搜索的一个字段和用于排序和聚合的多字段,或由不同分析器分析的相同字符串值。 | | [`include_in_all`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/include-in-all.html&usg=ALkJrhgG9Eb106moxBiIQnY_RNe0JdNslQ "include_in_all") | 字段值是否应包含在`[_all](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-all-field.html)`字段中? 接受`true`或`false` 。如果[`index`](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-index.html)设置为`no` ,或者如果父[`object`](https://www.elastic.co/guide/en/elasticsearch/reference/current/object.html)字段将`include_in_all,默认`设置为`false。` 否则默认为`true` 。 | | [`index`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-index.html&usg=ALkJrhjDd2JjTHxFwTWIVGOI0jtRnFerSQ "指数") | 应该可以搜索该字段吗? 接受`true` (默认)或`false` 。 | | [`index_options`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/index-options.html&usg=ALkJrhgQjMZt-jQff64GWpfI4_uUZQXhng "index_options") | 索引中应存储哪些信息,以便搜索和突出显示。 默认为`positions` 。 | | [`norms`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/norms.html&usg=ALkJrhhQhhAljkCCEu4CRzb_QAKpnB-Ebg "规范") | 在评分查询时是否应考虑字段长度。 接受`true` (默认)或`false` 。 | | [`position_increment_gap`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/position-increment-gap.html&usg=ALkJrhij_VFqNMYfvb9WpQZRHKG4Bo-WDw "position_increment_gap") | 应该在字符串数组的每个元素之间插入的假项目位置的数量。 默认为在分析器上配置的`position_increment_gap` ,默认为`100` 。 `100`被选中,因为它阻止了匹配术语与字段值之间的合理大小的间隔(小于100)的短语查询。 | | [`store`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-store.html&usg=ALkJrhjnu1ugPHKcE2l9aGRTyKps04ZZuQ "商店") | 字段值是否应与[`_source`](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html)字段分开存储和检索。 接受`true`或`false` (默认)。 | | [`search_analyzer`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/search-analyzer.html&usg=ALkJrhjlUDDK1IODYLamOAaDkDghyQMDdg "search_analyzer") | [`analyzer`](https://www.elastic.co/guide/en/elasticsearch/reference/current/analyzer.html)应在搜索时使用在[`analyzed`](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-index.html)领域。 默认为`analyzer`设置。 | | [`search_quote_analyzer`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/analyzer.html&usg=ALkJrhjWYcEqRqAnSdiBQHby7_zK46-Dpw#search-quote-analyzer "search_quote_analyzer") | 在遇到短语时应在搜索时使用的分析器。 默认为`search_analyzer`设置。 | | [`similarity`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/similarity.html&usg=ALkJrhjJYQJNZkE-ZD-zKQFnUhYPAjJF6A "相似") | 应该使用哪种评分算法或*相似度* 。 默认为`BM25` 。 | | [`term_vector`](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://www.elastic.co/guide/en/elasticsearch/reference/current/term-vector.html&usg=ALkJrhgSxB9ohl9dspjVWXraJPmeDtVYZg "term_vector") | 是否应为[`analyzed`](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-index.html)字段存储术语向量。 默认为`no` 。 | 从2.x导入的索引不支持`text` 。 相反,他们会尝试将`text`降级为`string` 。 这使您可以将现有映射与旧版映射进行合并。 在升级到6.x之前,必须重新生成长命索引,但映射降级可让您有机会按照自己的时间表进行安排。