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
+26-13
Original file line number
Diff line number
Diff line change
@@ -104,11 +104,17 @@ 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 can 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
108
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:
109
+
In this case, the 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.
110
110
111
-
$$$synthetic-source-text-example-default$$$
111
+
These modifications can impact usage of `text` fields:
112
+
* 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 details. 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.
113
+
* Handling of `null` values is different. `text` fields ignore `null` values, but `keyword` fields support replacing `null` values with a value specified in the `null_value` parameter. This replacement is represented in synthetic source.
114
+
115
+
For example:
116
+
117
+
$$$synthetic-source-text-example-multi-field$$$
112
118
113
119
```console
114
120
PUT idx
@@ -127,8 +133,9 @@ PUT idx
127
133
"text": {
128
134
"type": "text",
129
135
"fields": {
130
-
"raw": {
131
-
"type": "keyword"
136
+
"kwd": {
137
+
"type": "keyword",
138
+
"null_value": "NA"
132
139
}
133
140
}
134
141
}
@@ -138,9 +145,10 @@ PUT idx
138
145
PUT idx/_doc/1
139
146
{
140
147
"text": [
148
+
null,
141
149
"the quick brown fox",
142
150
"the quick brown fox",
143
-
"jumped over the lazy dog"
151
+
"jumped over the lazy dog",
144
152
]
145
153
}
146
154
```
@@ -150,18 +158,15 @@ Will become:
150
158
```console-result
151
159
{
152
160
"text": [
153
-
"jumped over the lazy dog",
161
+
"jumped over the lazy dog"
162
+
"NA",
154
163
"the quick brown fox"
155
164
]
156
165
}
157
166
```
158
167
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
168
163
-
164
-
If the `text` field sets `store` to true then order and duplicates are preserved.
169
+
If the `text` field sets `store` to `true` then the sub-field is not used and no modifications are applied. For example:
0 commit comments