Apostrophe token filter

Apostrophe token filter

Strips all characters after an apostrophe, including the apostrophe itself.

This filter is included in Elasticsearch’s built-in Turkish language analyzer. It uses Lucene’s ApostropheFilter, which was built for the Turkish language.

Example

The following analyze API request demonstrates how the apostrophe token filter works.

  1. resp = client.indices.analyze(
  2. tokenizer="standard",
  3. filter=[
  4. "apostrophe"
  5. ],
  6. text="Istanbul'a veya Istanbul'dan",
  7. )
  8. print(resp)
  1. response = client.indices.analyze(
  2. body: {
  3. tokenizer: 'standard',
  4. filter: [
  5. 'apostrophe'
  6. ],
  7. text: "Istanbul'a veya Istanbul'dan"
  8. }
  9. )
  10. puts response
  1. const response = await client.indices.analyze({
  2. tokenizer: "standard",
  3. filter: ["apostrophe"],
  4. text: "Istanbul'a veya Istanbul'dan",
  5. });
  6. console.log(response);
  1. GET /_analyze
  2. {
  3. "tokenizer" : "standard",
  4. "filter" : ["apostrophe"],
  5. "text" : "Istanbul'a veya Istanbul'dan"
  6. }

The filter produces the following tokens:

  1. [ Istanbul, veya, Istanbul ]

Add to an analyzer

The following create index API request uses the apostrophe token filter to configure a new custom analyzer.

  1. resp = client.indices.create(
  2. index="apostrophe_example",
  3. settings={
  4. "analysis": {
  5. "analyzer": {
  6. "standard_apostrophe": {
  7. "tokenizer": "standard",
  8. "filter": [
  9. "apostrophe"
  10. ]
  11. }
  12. }
  13. }
  14. },
  15. )
  16. print(resp)
  1. response = client.indices.create(
  2. index: 'apostrophe_example',
  3. body: {
  4. settings: {
  5. analysis: {
  6. analyzer: {
  7. standard_apostrophe: {
  8. tokenizer: 'standard',
  9. filter: [
  10. 'apostrophe'
  11. ]
  12. }
  13. }
  14. }
  15. }
  16. }
  17. )
  18. puts response
  1. const response = await client.indices.create({
  2. index: "apostrophe_example",
  3. settings: {
  4. analysis: {
  5. analyzer: {
  6. standard_apostrophe: {
  7. tokenizer: "standard",
  8. filter: ["apostrophe"],
  9. },
  10. },
  11. },
  12. },
  13. });
  14. console.log(response);
  1. PUT /apostrophe_example
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "standard_apostrophe": {
  7. "tokenizer": "standard",
  8. "filter": [ "apostrophe" ]
  9. }
  10. }
  11. }
  12. }
  13. }