@@ -32,7 +32,7 @@ To see how the `flatten_graph` filter works, you first need to produce a token
3232graph containing multi-position tokens.
3333
3434The following <<indices-analyze,analyze API>> request uses the `synonym_graph`
35- filter to add `dns ` as a multi-position synonym for `domain name system` in the
35+ filter to add `internet phonebook ` as a multi-position synonym for `domain name system` in the
3636text `domain name system is fragile`:
3737
3838[source,console]
@@ -43,65 +43,73 @@ GET /_analyze
4343 "filter": [
4444 {
4545 "type": "synonym_graph",
46- "synonyms": [ "dns , domain name system" ]
46+ "synonyms": [ "internet phonebook , domain name system" ]
4747 }
4848 ],
4949 "text": "domain name system is fragile"
5050}
5151----
5252
53- The filter produces the following token graph with `dns ` as a multi-position
53+ The filter produces the following token graph with `internet phonebook ` as a multi-position
5454token.
5555
56- image::images/analysis/token-graph-dns-synonym-ex .svg[align="center"]
56+ image::images/analysis/token-graph-dns-synonym-ex2 .svg[align="center"]
5757
5858////
5959[source,console-result]
6060----
6161{
6262 "tokens": [
6363 {
64- "token": "dns ",
64+ "token": "internet ",
6565 "start_offset": 0,
6666 "end_offset": 18,
6767 "type": "SYNONYM",
68- "position": 0,
69- "positionLength": 3
68+ "position": 0
7069 },
7170 {
7271 "token": "domain",
7372 "start_offset": 0,
7473 "end_offset": 6,
7574 "type": "<ALPHANUM>",
76- "position": 0
75+ "position": 0,
76+ "positionLength": 2
77+ },
78+ {
79+ "token": "phonebook",
80+ "start_offset": 0,
81+ "end_offset": 18,
82+ "type": "SYNONYM",
83+ "position": 1,
84+ "positionLength": 3
7785 },
7886 {
7987 "token": "name",
8088 "start_offset": 7,
8189 "end_offset": 11,
8290 "type": "<ALPHANUM>",
83- "position": 1
91+ "position": 2
8492 },
8593 {
8694 "token": "system",
8795 "start_offset": 12,
8896 "end_offset": 18,
8997 "type": "<ALPHANUM>",
90- "position": 2
98+ "position": 3
9199 },
92100 {
93101 "token": "is",
94102 "start_offset": 19,
95103 "end_offset": 21,
96104 "type": "<ALPHANUM>",
97- "position": 3
105+ "position": 4
98106 },
99107 {
100108 "token": "fragile",
101109 "start_offset": 22,
102110 "end_offset": 29,
103111 "type": "<ALPHANUM>",
104- "position": 4
112+ "position": 5
105113 }
106114 ]
107115}
@@ -122,7 +130,7 @@ GET /_analyze
122130 "filter": [
123131 {
124132 "type": "synonym_graph",
125- "synonyms": [ "dns , domain name system" ]
133+ "synonyms": [ "internet phonebook , domain name system" ]
126134 },
127135 "flatten_graph"
128136 ],
@@ -133,20 +141,19 @@ GET /_analyze
133141The filter produces the following flattened token graph, which is suitable for
134142indexing.
135143
136- image::images/analysis/token-graph-dns-invalid-ex .svg[align="center"]
144+ image::images/analysis/token-graph-dns-synonym-flattened-ex2 .svg[align="center"]
137145
138146////
139147[source,console-result]
140148----
141149{
142150 "tokens": [
143151 {
144- "token": "dns ",
152+ "token": "internet ",
145153 "start_offset": 0,
146- "end_offset": 18 ,
154+ "end_offset": 6 ,
147155 "type": "SYNONYM",
148- "position": 0,
149- "positionLength": 3
156+ "position": 0
150157 },
151158 {
152159 "token": "domain",
@@ -155,6 +162,14 @@ image::images/analysis/token-graph-dns-invalid-ex.svg[align="center"]
155162 "type": "<ALPHANUM>",
156163 "position": 0
157164 },
165+ {
166+ "token": "phonebook",
167+ "start_offset": 7,
168+ "end_offset": 18,
169+ "type": "SYNONYM",
170+ "position": 1,
171+ "positionLength": 2
172+ },
158173 {
159174 "token": "name",
160175 "start_offset": 7,
@@ -224,4 +239,4 @@ PUT /my-index-000001
224239 }
225240 }
226241}
227- ----
242+ ----
0 commit comments