|
1 | 1 | [[analysis-apostrophe-tokenfilter]]
|
2 |
| -=== Apostrophe Token Filter |
| 2 | +=== Apostrophe token filter |
| 3 | +++++ |
| 4 | +<titleabbrev>Apostrophe</titleabbrev> |
| 5 | +++++ |
3 | 6 |
|
4 |
| -The `apostrophe` token filter strips all characters after an apostrophe, |
5 |
| -including the apostrophe itself. |
| 7 | +Strips all characters after an apostrophe, including the apostrophe itself. |
| 8 | + |
| 9 | +This filter is included in {es}'s built-in <<turkish-analyzer,Turkish language |
| 10 | +analyzer>>. It uses Lucene's |
| 11 | +https://lucene.apache.org/core/4_8_0/analyzers-common/org/apache/lucene/analysis/tr/ApostropheFilter.html[ApostropheFilter], |
| 12 | +which was built for the Turkish language. |
| 13 | + |
| 14 | + |
| 15 | +[[analysis-apostrophe-tokenfilter-analyze-ex]] |
| 16 | +==== Example |
| 17 | + |
| 18 | +The following <<indices-analyze,analyze API>> request demonstrates how the |
| 19 | +apostrophe token filter works. |
| 20 | + |
| 21 | +[source,console] |
| 22 | +-------------------------------------------------- |
| 23 | +GET /_analyze |
| 24 | +{ |
| 25 | + "tokenizer" : "standard", |
| 26 | + "filter" : ["apostrophe"], |
| 27 | + "text" : "Istanbul'a veya Istanbul'dan" |
| 28 | +} |
| 29 | +-------------------------------------------------- |
| 30 | + |
| 31 | +The filter produces the following tokens: |
| 32 | + |
| 33 | +[source,text] |
| 34 | +-------------------------------------------------- |
| 35 | +[ Istanbul, veya, Istanbul ] |
| 36 | +-------------------------------------------------- |
| 37 | + |
| 38 | +///////////////////// |
| 39 | +[source,console-result] |
| 40 | +-------------------------------------------------- |
| 41 | +{ |
| 42 | + "tokens" : [ |
| 43 | + { |
| 44 | + "token" : "Istanbul", |
| 45 | + "start_offset" : 0, |
| 46 | + "end_offset" : 10, |
| 47 | + "type" : "<ALPHANUM>", |
| 48 | + "position" : 0 |
| 49 | + }, |
| 50 | + { |
| 51 | + "token" : "veya", |
| 52 | + "start_offset" : 11, |
| 53 | + "end_offset" : 15, |
| 54 | + "type" : "<ALPHANUM>", |
| 55 | + "position" : 1 |
| 56 | + }, |
| 57 | + { |
| 58 | + "token" : "Istanbul", |
| 59 | + "start_offset" : 16, |
| 60 | + "end_offset" : 28, |
| 61 | + "type" : "<ALPHANUM>", |
| 62 | + "position" : 2 |
| 63 | + } |
| 64 | + ] |
| 65 | +} |
| 66 | +-------------------------------------------------- |
| 67 | +///////////////////// |
| 68 | + |
| 69 | +[[analysis-apostrophe-tokenfilter-analyzer-ex]] |
| 70 | +==== Add to an analyzer |
| 71 | + |
| 72 | +The following <<indices-create-index,create index API>> request uses the |
| 73 | +apostrophe token filter to configure a new |
| 74 | +<<analysis-custom-analyzer,custom analyzer>>. |
| 75 | + |
| 76 | +[source,console] |
| 77 | +-------------------------------------------------- |
| 78 | +PUT /apostrophe_example |
| 79 | +{ |
| 80 | + "settings" : { |
| 81 | + "analysis" : { |
| 82 | + "analyzer" : { |
| 83 | + "standard_apostrophe" : { |
| 84 | + "tokenizer" : "standard", |
| 85 | + "filter" : ["apostrophe"] |
| 86 | + } |
| 87 | + } |
| 88 | + } |
| 89 | + } |
| 90 | +} |
| 91 | +-------------------------------------------------- |
0 commit comments