# Case insensitive phrase suggester?

**URL:** <https://discuss.elastic.co/t/case-insensitive-phrase-suggester/160946>\
**Category:** Elasticsearch\
**Created:** [December 14, 2018, 5:00pm UTC](https://discuss.elastic.co/t/case-insensitive-phrase-suggester/160946 "2018-12-14T17:00:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![boeingx](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@boeingx](https://discuss.elastic.co/u/boeingx)\
**Post date:** [December 14, 2018, 5:00pm UTC](https://discuss.elastic.co/t/case-insensitive-phrase-suggester/160946/1 "2018-12-14T17:00:10Z")

</div>

Hi!

Is it possible to perform case insensitive match with phrase suggester? Follow [the example in the documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html#_api_example), if we do

```auto
PUT test
{
  "settings": {
    "index": {
      "number_of_shards": 1,
      "analysis": {
        "analyzer": {
          "trigram": {
            "type": "custom",
            "tokenizer": "standard",
            "filter": ["shingle"]
          }
        },
        "filter": {
          "shingle": {
            "type": "shingle",
            "min_shingle_size": 2,
            "max_shingle_size": 3
          }
        }
      }
    }
  },
  "mappings": {
    "_doc": {
      "properties": {
        "title": {
          "type": "text",
          "fields": {
            "trigram": {
              "type": "text",
              "analyzer": "trigram"
            }
          }
        }
      }
    }
  }
}
POST test/_doc?refresh=true
{"title": "noble warriors"}
POST test/_doc?refresh=true
{"title": "Nobel Prize"}

```

then

```auto
POST test/_search
{
  "suggest": {
    "text": "noble prize",
    "simple_phrase": {
      "phrase": {
        "field": "title.trigram",
        "size": 1,
        "gram_size": 3,
        "direct_generator": [ {
          "field": "title.trigram",
          "suggest_mode": "always"
        } ],
        "highlight": {
          "pre_tag": "<em>",
          "post_tag": "</em>"
        }
      }
    }
  }
}

```

returns nothing.

On the other hand, if we add a `lowercase` filter to the `trigram` analyzer

```auto
PUT test
{
  "settings": {
    "index": {
      "number_of_shards": 1,
      "analysis": {
        "analyzer": {
          "trigram": {
            "type": "custom",
            "tokenizer": "standard",
            "filter": ["lowercase", "shingle"]
          }
        },
        "filter": {
          "shingle": {
            "type": "shingle",
            "min_shingle_size": 2,
            "max_shingle_size": 3
          }
        }
      }
    }
  },
  "mappings": {
    "_doc": {
      "properties": {
        "title": {
          "type": "text",
          "fields": {
            "trigram": {
              "type": "text",
              "analyzer": "trigram"
            }
          }
        }
      }
    }
  }
}
POST test/_doc?refresh=true
{"title": "noble warriors"}
POST test/_doc?refresh=true
{"title": "Nobel Prize"}

```

then

```auto
POST test/_search
{
  "suggest": {
    "text": "noble prize",
    "simple_phrase": {
      "phrase": {
        "field": "title.trigram",
        "size": 1,
        "gram_size": 3,
        "direct_generator": [ {
          "field": "title.trigram",
          "suggest_mode": "always"
        } ],
        "highlight": {
          "pre_tag": "<em>",
          "post_tag": "</em>"
        }
      }
    }
  }
}

```

returns `nobel prize` as suggestion.

My question is: can we combine the best of the two worlds? Is it possible to perform case insensitive match and yet returns the original text?

Thank you 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 11, 2019, 5:00pm UTC](https://discuss.elastic.co/t/case-insensitive-phrase-suggester/160946/2 "2019-01-11T17:00:15Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
