Skip to content

Commit aeab02b

Browse files
committed
Update analyze example
1 parent 111bf9b commit aeab02b

1 file changed

Lines changed: 68 additions & 30 deletions

File tree

docs/reference/analysis/tokenfilters/edgengram-tokenfilter.asciidoc

Lines changed: 68 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ beginning of a token. These edge n-grams are useful for
2525
==== Example
2626

2727
The following <<indices-analyze,analyze API>> request uses the `edge_ngram`
28-
filter to convert `the quick brown fox jumps` to 1-character edge n-grams:
28+
filter to convert `the quick brown fox jumps` to 1-character and 2-character
29+
edge n-grams:
2930

3031
[source,console]
3132
--------------------------------------------------
3233
GET _analyze
3334
{
3435
"tokenizer": "standard",
35-
"filter": [ "edge_ngram" ],
36+
"filter": [
37+
{ "type": "edge_ngram" }
38+
],
3639
"text": "the quick brown fox jumps"
3740
}
3841
--------------------------------------------------
@@ -41,48 +44,83 @@ The filter produces the following tokens:
4144

4245
[source,text]
4346
--------------------------------------------------
44-
[ t, q, b, f, j ]
47+
[ t, th, q, ui, b, br, f, fo, j, ju ]
4548
--------------------------------------------------
4649

4750
/////////////////////
4851
[source,console-result]
4952
--------------------------------------------------
5053
{
51-
"tokens": [
54+
"tokens" : [
5255
{
53-
"token": "t",
54-
"start_offset": 0,
55-
"end_offset": 3,
56-
"type": "<ALPHANUM>",
57-
"position": 0
56+
"token" : "t",
57+
"start_offset" : 0,
58+
"end_offset" : 3,
59+
"type" : "<ALPHANUM>",
60+
"position" : 0
5861
},
5962
{
60-
"token": "q",
61-
"start_offset": 4,
62-
"end_offset": 9,
63-
"type": "<ALPHANUM>",
64-
"position": 1
63+
"token" : "th",
64+
"start_offset" : 0,
65+
"end_offset" : 3,
66+
"type" : "<ALPHANUM>",
67+
"position" : 0
6568
},
6669
{
67-
"token": "b",
68-
"start_offset": 10,
69-
"end_offset": 15,
70-
"type": "<ALPHANUM>",
71-
"position": 2
70+
"token" : "q",
71+
"start_offset" : 4,
72+
"end_offset" : 9,
73+
"type" : "<ALPHANUM>",
74+
"position" : 1
7275
},
7376
{
74-
"token": "f",
75-
"start_offset": 16,
76-
"end_offset": 19,
77-
"type": "<ALPHANUM>",
78-
"position": 3
77+
"token" : "qu",
78+
"start_offset" : 4,
79+
"end_offset" : 9,
80+
"type" : "<ALPHANUM>",
81+
"position" : 1
7982
},
8083
{
81-
"token": "j",
82-
"start_offset": 20,
83-
"end_offset": 25,
84-
"type": "<ALPHANUM>",
85-
"position": 4
84+
"token" : "b",
85+
"start_offset" : 10,
86+
"end_offset" : 15,
87+
"type" : "<ALPHANUM>",
88+
"position" : 2
89+
},
90+
{
91+
"token" : "br",
92+
"start_offset" : 10,
93+
"end_offset" : 15,
94+
"type" : "<ALPHANUM>",
95+
"position" : 2
96+
},
97+
{
98+
"token" : "f",
99+
"start_offset" : 16,
100+
"end_offset" : 19,
101+
"type" : "<ALPHANUM>",
102+
"position" : 3
103+
},
104+
{
105+
"token" : "fo",
106+
"start_offset" : 16,
107+
"end_offset" : 19,
108+
"type" : "<ALPHANUM>",
109+
"position" : 3
110+
},
111+
{
112+
"token" : "j",
113+
"start_offset" : 20,
114+
"end_offset" : 25,
115+
"type" : "<ALPHANUM>",
116+
"position" : 4
117+
},
118+
{
119+
"token" : "ju",
120+
"start_offset" : 20,
121+
"end_offset" : 25,
122+
"type" : "<ALPHANUM>",
123+
"position" : 4
86124
}
87125
]
88126
}
@@ -103,7 +141,7 @@ PUT edge_ngram_example
103141
"settings": {
104142
"analysis": {
105143
"analyzer": {
106-
"standard_ngram": {
144+
"standard_edge_ngram": {
107145
"tokenizer": "standard",
108146
"filter": [ "edge_ngram" ]
109147
}

0 commit comments

Comments
 (0)