# Phrase suggester for not\_analyzed?

**URL:** <https://discuss.elastic.co/t/phrase-suggester-for-not-analyzed/37667>\
**Category:** Elasticsearch\
**Created:** [December 21, 2015, 7:54am UTC](https://discuss.elastic.co/t/phrase-suggester-for-not-analyzed/37667 "2015-12-21T07:54:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![111106](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/111106/32/6665_2.png) [@111106](https://discuss.elastic.co/u/111106)\
**Post date:** [December 21, 2015, 7:54am UTC](https://discuss.elastic.co/t/phrase-suggester-for-not-analyzed/37667/1 "2015-12-21T07:54:37Z")

</div>

Is it possible to use a phrase suggester on fields that are indexed as not\_analyzed? For some reason, I keep getting empty results.

Query looks something like:

```auto
POST http://localhost:9200/companies/_suggest
{
  "text" : "angel",
  "names" : {
    "phrase" : {
      "field" : "filter.name",
      "direct_generator": [
        {
          "field" : "filter.name",
          "suggest_mode" : "popular",
          "prefix_length": 2,
          "min_word_length": 3
        }
        ]
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 21, 2015, 2:01pm UTC](https://discuss.elastic.co/t/phrase-suggester-for-not-analyzed/37667/2 "2015-12-21T14:01:09Z")

</div>

> [@111106](#):
>
> Is it possible to use a phrase suggester on fields that are indexed as not\_analyzed?

Probably not. I haven't tried but I know that code reasonably well and it wants to use the analyzer for things. What are you trying to do?

---

<div class="post-metadata">

**Author:** ![111106](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/111106/32/6665_2.png) [@111106](https://discuss.elastic.co/u/111106)\
**Post date:** [December 21, 2015, 2:55pm UTC](https://discuss.elastic.co/t/phrase-suggester-for-not-analyzed/37667/3 "2015-12-21T14:55:18Z")

</div>

Well, I'd like to utilize some sort of error correction functionality and, optionally, an autocomplete. I have the same data indexed with nGrams and morphology plugins, but when I use the suggester on those fields, it basically results in some awkward tokens being returned instead.

What would you recommend?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 21, 2015, 3:16pm UTC](https://discuss.elastic.co/t/phrase-suggester-for-not-analyzed/37667/4 "2015-12-21T15:16:32Z")

</div>

> [@111106](#):
>
> What would you recommend?

Will the term suggester work for you?

---

<div class="post-metadata">

**Author:** ![111106](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/111106/32/6665_2.png) [@111106](https://discuss.elastic.co/u/111106)\
**Post date:** [December 21, 2015, 4:27pm UTC](https://discuss.elastic.co/t/phrase-suggester-for-not-analyzed/37667/5 "2015-12-21T16:27:05Z")

</div>

> [@nik9000](#):
>
> Will the term suggester work for you?

I don't think it works well on fields analyzed with nGrams. I tried it on not\_analyzed fields and pretty much got the same, empty result.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 21, 2015, 4:41pm UTC](https://discuss.elastic.co/t/phrase-suggester-for-not-analyzed/37667/6 "2015-12-21T16:41:43Z")

</div>

Sorry! I wouldn't point the suggester at a field that uses the ngram tokenizer either....

What about using the keyword analyzer instead of not\_analyzed?

---

<div class="post-metadata">

**Author:** ![111106](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/111106/32/6665_2.png) [@111106](https://discuss.elastic.co/u/111106)\
**Post date:** [December 21, 2015, 5:29pm UTC](https://discuss.elastic.co/t/phrase-suggester-for-not-analyzed/37667/7 "2015-12-21T17:29:00Z")

</div>

> [@nik9000](#):
>
> What about using the keyword analyzer instead of not\_analyzed?

I have to look into it, thank you. The reason I'm having duplicate, non-analyzed data is to be able to fetch documents with term filters. Would a keyword analyzer affect that?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 21, 2015, 6:34pm UTC](https://discuss.elastic.co/t/phrase-suggester-for-not-analyzed/37667/8 "2015-12-21T18:34:02Z")

</div>

> [@111106](#):
>
> Would a keyword analyzer affect that?

It should look the same as not\_analyzed. Its worth testing that it does and that it helps on a smaller dataset first though.

---

<div class="post-metadata">

**Author:** ![111106](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/111106/32/6665_2.png) [@111106](https://discuss.elastic.co/u/111106)\
**Post date:** [December 22, 2015, 12:44pm UTC](https://discuss.elastic.co/t/phrase-suggester-for-not-analyzed/37667/9 "2015-12-22T12:44:53Z")

</div>

I've tried indexing a few documents with a `keyword` analyzer. I've started getting _some_ results, which are still very far from what I'm trying to achieve.

For example, I have a document which has a `name` 'Music'. If I want a suggestion for 'Musi', ES returns 'Music'. But if I type it with a lowercase, 'musi', it returns nothing, which is definitely not what I want.

I've tried using suggest-time analyzers with lowercasing, but those don't seem to help. Anything else I can do?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 22, 2015, 2:31pm UTC](https://discuss.elastic.co/t/phrase-suggester-for-not-analyzed/37667/10 "2015-12-22T14:31:55Z")

</div>

> [@111106](#):
>
> I've tried using suggest-time analyzers with lowercasing, but those don't seem to help. Anything else I can do?

Sure! Lots of stuff! It depends on which way you want the suggestions to work:

1. Use a custom analyzer that has the keyword tokenizer and a lowercase filter. That should make 'musi' return 'music' but should also make 'Musi' return 'music'. Because all the tokens are now lowercased.

2. You may be able write an analyzer that uppercases the first letter and use it with the `analyzer` option. I have lots less experience with this and don't remember how that code works.

3. There looks like there is a `lowercase_terms` option too which might do something for you as well.

It makes you life much easier if you are ok with 'Musi' suggesting 'music'.

---

<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:** [July 5, 2017, 11:29pm UTC](https://discuss.elastic.co/t/phrase-suggester-for-not-analyzed/37667/11 "2017-07-05T23:29:19Z")

</div>


