Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<indices-analyze,analyze API>> 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]
Expand All @@ -43,65 +43,73 @@ 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]
----
{
"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": "<ALPHANUM>",
"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": "<ALPHANUM>",
"position": 1
"position": 2
},
{
"token": "system",
"start_offset": 12,
"end_offset": 18,
"type": "<ALPHANUM>",
"position": 2
"position": 3
},
{
"token": "is",
"start_offset": 19,
"end_offset": 21,
"type": "<ALPHANUM>",
"position": 3
"position": 4
},
{
"token": "fragile",
"start_offset": 22,
"end_offset": 29,
"type": "<ALPHANUM>",
"position": 4
"position": 5
}
]
}
Expand All @@ -122,7 +130,7 @@ GET /_analyze
"filter": [
{
"type": "synonym_graph",
"synonyms": [ "dns, domain name system" ]
"synonyms": [ "internet phonebook, domain name system" ]
},
"flatten_graph"
],
Expand All @@ -133,20 +141,19 @@ 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]
----
{
"tokens": [
{
"token": "dns",
"token": "internet",
"start_offset": 0,
"end_offset": 18,
"end_offset": 6,
"type": "SYNONYM",
"position": 0,
"positionLength": 3
"position": 0
},
{
"token": "domain",
Expand All @@ -155,6 +162,14 @@ image::images/analysis/token-graph-dns-invalid-ex.svg[align="center"]
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "phonebook",
"start_offset": 7,
"end_offset": 18,
"type": "SYNONYM",
"position": 1,
"positionLength": 2
},
{
"token": "name",
"start_offset": 7,
Expand Down Expand Up @@ -224,4 +239,4 @@ PUT /my-index-000001
}
}
}
----
----
Loading
Loading