You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/elasticsearch/mapping-reference/text.md
+13-51Lines changed: 13 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -104,11 +104,20 @@ Synthetic `_source` is Generally Available only for TSDB indices (indices that h
104
104
::::
105
105
106
106
107
-
`text` fields support [synthetic `_source`](/reference/elasticsearch/mapping-reference/mapping-source-field.md#synthetic-source) if they have a [`keyword`](/reference/elasticsearch/mapping-reference/keyword.md#keyword-synthetic-source) sub-field that supports synthetic `_source` or if the `text` field sets `store` to `true`. Either way, it may not have [`copy_to`](/reference/elasticsearch/mapping-reference/copy-to.md).
107
+
`text` fields may use a [`keyword`](/reference/elasticsearch/mapping-reference/keyword.md#keyword-synthetic-source) sub-field to support [synthetic `_source`](/reference/elasticsearch/mapping-reference/mapping-source-field.md#synthetic-source) without storing values of the text field itself.
108
+
109
+
::::{note}
110
+
Synthetic source of the `text` field will have the same [modifications](/reference/elasticsearch/mapping-reference/mapping-source-field.md#synthetic-source) as a `keyword` field in this case.
111
+
112
+
These modifications can impact usage of `text` fields:
113
+
* Reordering text fields can have an effect on [phrase](/reference/query-languages/query-dsl/query-dsl-match-query-phrase.md) and [span](/reference/query-languages/query-dsl/span-queries.md) queries. See the discussion about [`position_increment_gap`](/reference/elasticsearch/mapping-reference/position-increment-gap.md) for more detail. You can avoid this by making sure the `slop` parameter on the phrase queries is lower than the `position_increment_gap`. This is the default.
114
+
* Handling of `null` values is different. `text` fields ignore `null` values but `keyword` fields support replacing `null`s with a value specified in the `null_value` parameter. This replacement will be represented in synthetic source.
115
+
::::
108
116
109
-
If using a sub-`keyword` field, then the values are sorted in the same way as a `keyword` field’s values are sorted. By default, that means sorted with duplicates removed. So:
110
117
111
-
$$$synthetic-source-text-example-default$$$
118
+
If the `text` field sets `store` to `true` then the sub-field is not used and modifications mentioned above do not apply.
119
+
120
+
$$$synthetic-source-text-example-stored$$$
112
121
113
122
```console
114
123
PUT idx
@@ -126,6 +135,7 @@ PUT idx
126
135
"properties": {
127
136
"text": {
128
137
"type": "text",
138
+
"store": true,
129
139
"fields": {
130
140
"raw": {
131
141
"type": "keyword"
@@ -147,54 +157,6 @@ PUT idx/_doc/1
147
157
148
158
Will become:
149
159
150
-
```console-result
151
-
{
152
-
"text": [
153
-
"jumped over the lazy dog",
154
-
"the quick brown fox"
155
-
]
156
-
}
157
-
```
158
-
159
-
::::{note}
160
-
Reordering text fields can have an effect on [phrase](/reference/query-languages/query-dsl/query-dsl-match-query-phrase.md) and [span](/reference/query-languages/query-dsl/span-queries.md) queries. See the discussion about [`position_increment_gap`](/reference/elasticsearch/mapping-reference/position-increment-gap.md) for more detail. You can avoid this by making sure the `slop` parameter on the phrase queries is lower than the `position_increment_gap`. This is the default.
161
-
::::
162
-
163
-
164
-
If the `text` field sets `store` to true then order and duplicates are preserved.
0 commit comments