# Trouble with Phrase Suggester

**URL:** <https://discuss.elastic.co/t/trouble-with-phrase-suggester/96511>\
**Category:** Elasticsearch\
**Created:** [August 9, 2017, 9:03pm UTC](https://discuss.elastic.co/t/trouble-with-phrase-suggester/96511 "2017-08-09T21:03:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikhiltri](https://avatars.discourse-cdn.com/v4/letter/n/9fc348/32.png) [@nikhiltri](https://discuss.elastic.co/u/nikhiltri)\
**Post date:** [August 9, 2017, 9:03pm UTC](https://discuss.elastic.co/t/trouble-with-phrase-suggester/96511/1 "2017-08-09T21:03:47Z")

</div>

I'm having some trouble implementing the Phrase Suggester using the examples provided in the documentation ([https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html)).

I've got this mapping:

```
{
	"...": {
		"aliases": {},
		"mappings": {
			"agent": {
				"properties": {
					"title": {
						"type": "text",
						"fields": {
							"reverse": {
								"type": "text",
								"analyzer": "reverse"
							},
							"trigram": {
								"type": "text",
								"analyzer": "trigram"
							}
						}
					}
				}
			}
		},
		"settings": {
			"index": {
				"number_of_shards": "5",
				"provided_name": "...",
				"creation_date": "...",
				"analysis": {
					"filter": {
						"shingle": {
							"max_shingle_size": "3",
							"min_shingle_size": "2",
							"type": "shingle"
						},
						"english_stemmer": {
							"type": "stemmer",
							"language": "english"
						},
						"english_possessive_stemmer": {
							"type": "stemmer",
							"language": "possessive_english"
						},
						"english_stop": {
							"type": "stop",
							"stopwords": "_english_"
						}
					},
					"analyzer": {
						"reverse": {
							"filter": [
								"standard",
								"reverse"
							],
							"tokenizer": "standard"
						},
						"trigram": {
							"filter": [
								"standard",
								"shingle"
							],
							"tokenizer": "standard"
						},
						"default": {
							"filter": [
								"english_possessive_stemmer",
								"lowercase",
								"english_stop",
								"english_stemmer"
							],
							"tokenizer": "standard"
						}
					}
				},
				"number_of_replicas": "1",
				"uuid": "...",
				"version": {
					"created": "..."
				}
			}
		}
	}
}

```

With a document with the title "Rauschenberg, Robert", here is the search I'm trying to perform:

```
{
	"index": "...",
	"type": null,
	"body": {
		"query": {
			"bool": {
				"must": [{
					"multi_match": {
						"query": "Ruschenbrg, robert",
						"fuzziness": 3,
						"prefix_length": 1,
						"fields": ["_all"]
					}
				}],
				"should": [{
					"terms": {
						"id": [...]
					}
				}],
				"filter": null
			}
		},
		"suggest": {
			"text": "Ruschenbrg, robert",
			"phrase-suggest": {
				"phrase": {
					"field": "title.trigram",
					"gram_size": 3,
					"direct_generator": [{
						"field": "title.trigram",
						"suggest_mode": "always"
					}, {
						"field": "title.reverse",
						"suggest_mode": "always",
						"pre_filter": "reverse",
						"post_filter": "reverse"
					}],
					"highlight": {
						"pre_tag": "<em>",
						"post_tag": "<\/em>"
					}
				}
			}
		}
	}
}

```

And here are the results:

```
{
	"took": 33,
	"timed_out": false,
	"_shards": {
		"total": 5,
		"successful": 5,
		"failed": 0
	},
	"hits": {
		...
	},
	"suggest": {
		"phrase-suggest": [{
			"text": "Ruschenbrg, robert",
			"offset": 0,
			"length": 18,
			"options": []
		}]
	}
}

```

You'll see in the `suggest` block, the `options` parameter is empty. I would expect it to contain the title of the closely matched document "Rauschenberg, Robert". What am I missing?

---

<div class="post-metadata">

**Author:** ![nikhiltri](https://avatars.discourse-cdn.com/v4/letter/n/9fc348/32.png) [@nikhiltri](https://discuss.elastic.co/u/nikhiltri)\
**Post date:** [August 10, 2017, 4:13pm UTC](https://discuss.elastic.co/t/trouble-with-phrase-suggester/96511/2 "2017-08-10T16:13:39Z")

</div>

Figured it out. It turned out to be a type name mismatch between the mappings I was creating and the data I was indexing. So new types were being created that didn't include these extra fields and my data was being indexed there.

---

<div class="post-metadata">

**Author:** ![talevy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talevy/32/44896_2.png) [@talevy](https://discuss.elastic.co/u/talevy)\
**Post date:** [August 10, 2017, 5:07pm UTC](https://discuss.elastic.co/t/trouble-with-phrase-suggester/96511/3 "2017-08-10T17:07:05Z")

</div>

cool, glad to hear this was resolved!

---

<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:** [September 7, 2017, 5:07pm UTC](https://discuss.elastic.co/t/trouble-with-phrase-suggester/96511/4 "2017-09-07T17:07:09Z")

</div>

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