# Phrase suggester not returning any result

**URL:** <https://discuss.elastic.co/t/phrase-suggester-not-returning-any-result/81441>\
**Category:** Elasticsearch\
**Created:** [April 6, 2017, 10:02am UTC](https://discuss.elastic.co/t/phrase-suggester-not-returning-any-result/81441 "2017-04-06T10:02:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![usund](https://avatars.discourse-cdn.com/v4/letter/u/d26b3c/32.png) [@usund](https://discuss.elastic.co/u/usund)\
**Post date:** [April 6, 2017, 10:02am UTC](https://discuss.elastic.co/t/phrase-suggester-not-returning-any-result/81441/1 "2017-04-06T10:02:49Z")

</div>

Hi,  
I have created mapping for my index using dynamic template. Here goes my mapping  
{  
"testpis": {  
"mappings": {  
"product": {  
"\_all": {  
"enabled": false  
},  
"dynamic\_templates": [{  
"productname": {  
"match": "Product Name",  
"mapping": {  
"analyzer": "trigram",  
"type": "text"  
}  
}  
}, {  
"category": {  
"match": "Category",  
"mapping": {  
"analyzer": "trigram",  
"type": "text"  
}  
}  
}],  
"properties": {  
"data": {  
"properties": {  
"Brand": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"Category": {  
"type": "text",  
"analyzer": "trigram"  
},  
"Product Name": {  
"type": "text",  
"analyzer": "trigram"  
},  
"UPC/Bar code": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
}  
}  
},  
"name": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
}  
}  
},  
"_default_": {  
"\_all": {  
"enabled": false  
},  
"dynamic\_templates": [{  
"productname": {  
"match": "Product Name",  
"mapping": {  
"analyzer": "trigram",  
"type": "text"  
}  
}  
}, {  
"category": {  
"match": "Category",  
"mapping": {  
"analyzer": "trigram",  
"type": "text"  
}  
}  
}]  
}  
}  
}  
}

Now I am trying to use phrase suggester which looks like

searchRequestBuilder :: {  
"suggest" : {  
"sample\_suggest" : {  
"text" : "DEO",  
"phrase" : {  
"field" : "data.Category",  
"size" : 5,  
"real\_word\_error\_likelihood" : 0.95,  
"confidence" : 1.0,  
"separator" : " ",  
"max\_errors" : 0.5,  
"gram\_size" : 3,  
"force\_unigrams" : true,  
"token\_limit" : 10,  
"direct\_generator" : [  
{  
"field" : "data.Category",  
"suggest\_mode" : "always"  
}  
],  
"highlight" : {  
"pre\_tag" : "_",  
"post\_tag" : "\</em"  
}  
}  
}  
}  
}_

This is the code

PhraseSuggestionBuilder suggestion = new PhraseSuggestionBuilder("data.Category");  
suggestion.highlight("_", "_");  
suggestion.text("INSTANT MIX");  
suggestion.gramSize(2);  
suggestion.size(5);

```
		CandidateGenerator generator;
		DirectCandidateGeneratorBuilder directCandidateGeneratorBuilder = new DirectCandidateGeneratorBuilder("data.Category");
		directCandidateGeneratorBuilder.suggestMode("always");
		suggestion.addCandidateGenerator(directCandidateGeneratorBuilder);
		suggestBuilder.addSuggestion("sample_suggest", suggestion);

```

I am not getting any results. Can anyone tell me what is the problem? will dynamic template cause any problem in using suggester?

---

<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:** [May 4, 2017, 10:03am UTC](https://discuss.elastic.co/t/phrase-suggester-not-returning-any-result/81441/2 "2017-05-04T10:03:17Z")

</div>

Closed on May 4, 2017, 10:03am UTC

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