Update Flatten Graph Docs to Include a Real Flattened Graph 9.x (#123901)

updated flatten graph docs to include a real flattened graph
This commit is contained in:
John Wagster 2025-03-03 14:33:53 -06:00 committed by GitHub
parent 66a812321b
commit be577e382d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 8 deletions

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 20 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 19 KiB

View file

@ -25,7 +25,7 @@ The `flatten_graph` filter uses Lucenes [FlattenGraphFilter](https://lucene.a
To see how the `flatten_graph` filter works, you first need to produce a token graph containing multi-position tokens.
The following [analyze API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-analyze) request uses the `synonym_graph` filter to add `dns` as a multi-position synonym for `domain name system` in the text `domain name system is fragile`:
The following [analyze API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-analyze) request uses the `synonym_graph` filter to add `internet phonebook` as a multi-position synonym for `domain name system` in the text `domain name system is fragile`:
```console
GET /_analyze
@ -34,17 +34,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 token.
The filter produces the following token graph with `internet phonebook` as a multi-position token.
:::{image} ../../../images/token-graph-dns-synonym-ex.svg
:alt: token graph dns synonym ex
:::{image} ../../../images/token-graph-dns-synonym-ex2.svg
:alt: token graph dns synonym example
:::
Indexing does not support token graphs containing multi-position tokens. To make this token graph suitable for indexing, it needs to be flattened.
@ -58,7 +58,7 @@ GET /_analyze
"filter": [
{
"type": "synonym_graph",
"synonyms": [ "dns, domain name system" ]
"synonyms": [ "internet phonebook, domain name system" ]
},
"flatten_graph"
],
@ -68,8 +68,8 @@ GET /_analyze
The filter produces the following flattened token graph, which is suitable for indexing.
:::{image} ../../../images/token-graph-dns-invalid-ex.svg
:alt: token graph dns invalid ex
:::{image} ../../../images/token-graph-dns-synonym-flattened-ex2.svg
:alt: token graph dns flattened example
:::