From 576b5c16a517f1b2c62a4d286f3bfa1ca90c8cf6 Mon Sep 17 00:00:00 2001 From: John Wagster Date: Mon, 3 Mar 2025 11:28:57 -0600 Subject: [PATCH 1/3] updated flatten graph docs to include a real flattened graph --- .../flatten-graph-tokenfilter.asciidoc | 53 ++++++++++++------- .../analysis/token-graph-dns-synonym-ex2.svg | 2 + .../token-graph-dns-synonym-flattened-ex2.svg | 2 + 3 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 docs/reference/images/analysis/token-graph-dns-synonym-ex2.svg create mode 100644 docs/reference/images/analysis/token-graph-dns-synonym-flattened-ex2.svg diff --git a/docs/reference/analysis/tokenfilters/flatten-graph-tokenfilter.asciidoc b/docs/reference/analysis/tokenfilters/flatten-graph-tokenfilter.asciidoc index b719ea376a279..f2ec3d377eefc 100644 --- a/docs/reference/analysis/tokenfilters/flatten-graph-tokenfilter.asciidoc +++ b/docs/reference/analysis/tokenfilters/flatten-graph-tokenfilter.asciidoc @@ -32,7 +32,7 @@ To see how the `flatten_graph` filter works, you first need to produce a token graph containing multi-position tokens. The following <> request uses the `synonym_graph` -filter to add `dns` as a multi-position synonym for `domain name system` in the +filter to add `internet phonebook` as a multi-position synonym for `domain name system` in the text `domain name system is fragile`: [source,console] @@ -43,17 +43,17 @@ GET /_analyze "filter": [ { "type": "synonym_graph", - "synonyms": [ "dns, domain name system" ] + "synonyms": [ "internet phonebook, domain name system" ] } ], "text": "domain name system is fragile" } ---- -The filter produces the following token graph with `dns` as a multi-position +The filter produces the following token graph with `internet phonebook` as a multi-position token. -image::images/analysis/token-graph-dns-synonym-ex.svg[align="center"] +image::images/analysis/token-graph-dns-synonym-ex2.svg[align="center"] //// [source,console-result] @@ -61,47 +61,55 @@ image::images/analysis/token-graph-dns-synonym-ex.svg[align="center"] { "tokens": [ { - "token": "dns", + "token": "internet", "start_offset": 0, "end_offset": 18, "type": "SYNONYM", - "position": 0, - "positionLength": 3 + "position": 0 }, { "token": "domain", "start_offset": 0, "end_offset": 6, "type": "", - "position": 0 + "position": 0, + "positionLength": 2 + }, + { + "token": "phonebook", + "start_offset": 0, + "end_offset": 18, + "type": "SYNONYM", + "position": 1, + "positionLength": 3 }, { "token": "name", "start_offset": 7, "end_offset": 11, "type": "", - "position": 1 + "position": 2 }, { "token": "system", "start_offset": 12, "end_offset": 18, "type": "", - "position": 2 + "position": 3 }, { "token": "is", "start_offset": 19, "end_offset": 21, "type": "", - "position": 3 + "position": 4 }, { "token": "fragile", "start_offset": 22, "end_offset": 29, "type": "", - "position": 4 + "position": 5 } ] } @@ -122,7 +130,7 @@ GET /_analyze "filter": [ { "type": "synonym_graph", - "synonyms": [ "dns, domain name system" ] + "synonyms": [ "internet phonebook, domain name system" ] }, "flatten_graph" ], @@ -133,7 +141,7 @@ GET /_analyze The filter produces the following flattened token graph, which is suitable for indexing. -image::images/analysis/token-graph-dns-invalid-ex.svg[align="center"] +image::images/analysis/token-graph-dns-flattened-ex2.svg[align="center"] //// [source,console-result] @@ -141,12 +149,11 @@ image::images/analysis/token-graph-dns-invalid-ex.svg[align="center"] { "tokens": [ { - "token": "dns", + "token": "internet", "start_offset": 0, - "end_offset": 18, + "end_offset": 6, "type": "SYNONYM", - "position": 0, - "positionLength": 3 + "position": 0 }, { "token": "domain", @@ -155,6 +162,14 @@ image::images/analysis/token-graph-dns-invalid-ex.svg[align="center"] "type": "", "position": 0 }, + { + "token": "phonebook", + "start_offset": 7, + "end_offset": 18, + "type": "SYNONYM", + "position": 1, + "positionLength": 2 + }, { "token": "name", "start_offset": 7, @@ -224,4 +239,4 @@ PUT /my-index-000001 } } } ----- \ No newline at end of file +---- diff --git a/docs/reference/images/analysis/token-graph-dns-synonym-ex2.svg b/docs/reference/images/analysis/token-graph-dns-synonym-ex2.svg new file mode 100644 index 0000000000000..571f8489a2c2b --- /dev/null +++ b/docs/reference/images/analysis/token-graph-dns-synonym-ex2.svg @@ -0,0 +1,2 @@ +domainnamesystemisfragileinternetphonebook023451 \ No newline at end of file diff --git a/docs/reference/images/analysis/token-graph-dns-synonym-flattened-ex2.svg b/docs/reference/images/analysis/token-graph-dns-synonym-flattened-ex2.svg new file mode 100644 index 0000000000000..bc2dba35e522c --- /dev/null +++ b/docs/reference/images/analysis/token-graph-dns-synonym-flattened-ex2.svg @@ -0,0 +1,2 @@ +domainnamesystemisfragileinternetphonebook01234 \ No newline at end of file From 9d7c4b60280688ce306725b37d89f96d8ae9456f Mon Sep 17 00:00:00 2001 From: John Wagster Date: Mon, 3 Mar 2025 12:03:48 -0600 Subject: [PATCH 2/3] updated flatten graph docs to include a real flattened graph --- .../analysis/tokenfilters/flatten-graph-tokenfilter.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/analysis/tokenfilters/flatten-graph-tokenfilter.asciidoc b/docs/reference/analysis/tokenfilters/flatten-graph-tokenfilter.asciidoc index f2ec3d377eefc..457e7e544ad8e 100644 --- a/docs/reference/analysis/tokenfilters/flatten-graph-tokenfilter.asciidoc +++ b/docs/reference/analysis/tokenfilters/flatten-graph-tokenfilter.asciidoc @@ -141,7 +141,7 @@ GET /_analyze The filter produces the following flattened token graph, which is suitable for indexing. -image::images/analysis/token-graph-dns-flattened-ex2.svg[align="center"] +image::images/analysis/token-graph-dns-synonym-flattened-ex2.svg[align="center"] //// [source,console-result] From f35a254abc5ad40033bd875ecc69fc08ede3c682 Mon Sep 17 00:00:00 2001 From: John Wagster Date: Mon, 3 Mar 2025 13:18:08 -0600 Subject: [PATCH 3/3] fixing svgs to render more cleanly --- .../reference/images/analysis/token-graph-dns-synonym-ex2.svg | 4 ++-- .../images/analysis/token-graph-dns-synonym-flattened-ex2.svg | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/reference/images/analysis/token-graph-dns-synonym-ex2.svg b/docs/reference/images/analysis/token-graph-dns-synonym-ex2.svg index 571f8489a2c2b..4fe42552a3eb2 100644 --- a/docs/reference/images/analysis/token-graph-dns-synonym-ex2.svg +++ b/docs/reference/images/analysis/token-graph-dns-synonym-ex2.svg @@ -1,2 +1,2 @@ -domainnamesystemisfragileinternetphonebook023451 \ No newline at end of file +domainnamesystemisfragileinternetphonebook023451 diff --git a/docs/reference/images/analysis/token-graph-dns-synonym-flattened-ex2.svg b/docs/reference/images/analysis/token-graph-dns-synonym-flattened-ex2.svg index bc2dba35e522c..b7faa6570ad83 100644 --- a/docs/reference/images/analysis/token-graph-dns-synonym-flattened-ex2.svg +++ b/docs/reference/images/analysis/token-graph-dns-synonym-flattened-ex2.svg @@ -1,2 +1,2 @@ -domainnamesystemisfragileinternetphonebook01234 \ No newline at end of file +domainnamesystemisfragileinternetphonebook01234