Skip to content

Commit 2ade47d

Browse files
committed
add an example
1 parent 882ce67 commit 2ade47d

File tree

1 file changed

+54
-1
lines changed
  • docs/reference/elasticsearch/mapping-reference

1 file changed

+54
-1
lines changed

docs/reference/elasticsearch/mapping-reference/text.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,61 @@ These modifications can impact usage of `text` fields:
112112
* 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.
113113
* 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.
114114

115+
For example:
115116

116-
If the `text` field sets `store` to `true` then the sub-field is not used and no modifications are applied.
117+
$$$synthetic-source-text-example-multi-field$$$
118+
119+
```console
120+
PUT idx
121+
{
122+
"settings": {
123+
"index": {
124+
"mapping": {
125+
"source": {
126+
"mode": "synthetic"
127+
}
128+
}
129+
}
130+
},
131+
"mappings": {
132+
"properties": {
133+
"text": {
134+
"type": "text",
135+
"fields": {
136+
"kwd": {
137+
"type": "keyword",
138+
"null_value": "NA"
139+
}
140+
}
141+
}
142+
}
143+
}
144+
}
145+
PUT idx/_doc/1
146+
{
147+
"text": [
148+
null,
149+
"the quick brown fox",
150+
"the quick brown fox",
151+
"jumped over the lazy dog",
152+
]
153+
}
154+
```
155+
156+
Will become:
157+
158+
```console-result
159+
{
160+
"text": [
161+
"jumped over the lazy dog"
162+
"NA",
163+
"the quick brown fox"
164+
]
165+
}
166+
```
167+
168+
169+
If the `text` field sets `store` to `true` then the sub-field is not used and no modifications are applied. For example:
117170

118171
$$$synthetic-source-text-example-stored$$$
119172

0 commit comments

Comments
 (0)