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?