# How to have multiple type single suggest

**URL:** <https://discuss.elastic.co/t/how-to-have-multiple-type-single-suggest/21101>\
**Category:** Elasticsearch\
**Created:** [December 5, 2014, 7:50am UTC](https://discuss.elastic.co/t/how-to-have-multiple-type-single-suggest/21101 "2014-12-05T07:50:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![madan\_ram](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@madan\_ram](https://discuss.elastic.co/u/madan_ram)\
**Post date:** [December 5, 2014, 7:50am UTC](https://discuss.elastic.co/t/how-to-have-multiple-type-single-suggest/21101/1 "2014-12-05T07:50:02Z")

</div>

I want multiple type suggest for single request,  
eq I have data about some article and profile user data. So when we type I  
need to suggest profile user as well as user data in one request.

I tried

curl -X PUT localhost:9200/suggestion -d '  
{  
"mappings" : {  
"keyword" : {  
"properties" : {  
"name\_suggest" : { "type" : "completion"}  
}  
},  
"profiles" : {  
"properties" : {  
"name\_suggest" : { "type" : "completion"},  
"payload" : true  
}  
}  
}  
}'

my request is  
curl -X GET localhost:9200/suggestion/\_suggest?pretty -d '  
{  
"keyword" : {  
"text" : "a",  
"completion" : {  
"field" : "name\_suggest"  
}  
},  
"profiles" : {  
"text" : "a",  
"completion" : {  
"field" : "name\_suggest"  
}  
}  
}'

It need to return

{  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"keyword" : [ {  
"text" : "a",  
"offset" : 0,  
"length" : 1,  
"options" : [ {  
"text" : "aba",  
"score" : 1.0  
}, {  
"text" : "abaca",  
"score" : 1.0  
}, {  
"text" : "abandoned land",  
"score" : 1.0  
}, {  
"text" : "abelmoschus esculentus",  
"score" : 1.0  
}, {  
"text" : "abies balsamea",  
"score" : 1.0  
} ]  
} ],  
"profiles" : [ {  
{  
"text" : "abhi dath",  
"score" : 1.0  
}, {  
"text" : "anney lotra",  
"score" : 1.0  
} ]  
} ]  
}

but I get

{  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"keyword" : [ {  
"text" : "a",  
"offset" : 0,  
"length" : 1,  
"options" : [ {  
"text" : "aba",  
"score" : 1.0  
}, {  
"text" : "abaca",  
"score" : 1.0  
}, {  
"text" : "abandoned land",  
"score" : 1.0  
}, {  
"text" : "abelmoschus esculentus",  
"score" : 1.0  
}, {  
"text" : "abies balsamea",  
"score" : 1.0  
} ]  
} ],  
"profiles" : [ {  
"text" : "a",  
"offset" : 0,  
"length" : 1,  
"options" : [ {  
"text" : "aba",  
"score" : 1.0  
}, {  
"text" : "abaca",  
"score" : 1.0  
}, {  
"text" : "abandoned land",  
"score" : 1.0  
}, {  
"text" : "abelmoschus esculentus",  
"score" : 1.0  
}, {  
"text" : "abies balsamea",  
"score" : 1.0  
} ]  
} ]  
}

what is wrong ?, Is there any other approach

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0c7bb180-cbd0-4807-a172-acb6b5818b59%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0c7bb180-cbd0-4807-a172-acb6b5818b59%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Michael\_Gallego](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_gallego/32/933_2.png) [@Michael\_Gallego](https://discuss.elastic.co/u/Michael_Gallego)\
**Post date:** [December 5, 2014, 11:34pm UTC](https://discuss.elastic.co/t/how-to-have-multiple-type-single-suggest/21101/2 "2014-12-05T23:34:23Z")

</div>

Hi,

Suggester does not work the same way as normal queries and is not aware of  
types, so the output is expected. As you have two suggesters with same  
name, it will return the same results. You should use the context  
suggester, that adds a context  
([http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/suggester-context.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/suggester-context.html)),  
so that you can differentiate. To avoid any ambiguity, I tend to have more  
verbose name for my suggesters are they are not type aware (so instead of  
"name\_suggest" I would call them "keyword\_name\_suggest" and  
"profile\_name\_suggest"). If you do so, you basically don't need to use the  
"context suggester". If you want to keep the same name, you'll have to use  
a context suggester.

Hope it helps!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/568f322f-39df-4967-ab03-69dfe6aa54bc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/568f322f-39df-4967-ab03-69dfe6aa54bc%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:45am UTC](https://discuss.elastic.co/t/how-to-have-multiple-type-single-suggest/21101/3 "2017-07-06T00:45:22Z")

</div>

Closed on July 6, 2017, 12:45am UTC


