# Getting Search suggestion from secondary field

**URL:** <https://discuss.elastic.co/t/getting-search-suggestion-from-secondary-field/299846>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [March 16, 2022, 9:37am UTC](https://discuss.elastic.co/t/getting-search-suggestion-from-secondary-field/299846 "2022-03-16T09:37:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Himanshu\_Jain3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/himanshu_jain3/32/103109_2.png) [@Himanshu\_Jain3](https://discuss.elastic.co/u/Himanshu_Jain3)\
**Post date:** [March 16, 2022, 9:37am UTC](https://discuss.elastic.co/t/getting-search-suggestion-from-secondary-field/299846/1 "2022-03-16T09:37:12Z")

</div>

Please sugest a way where we can provide user with suggestion from second field other then the matchin field

Example

[Name] [Address] [Phone no]  
Pooja Tower , Gopalpura mode Jaipur , xxxxxxxxx  
Balaji Hotel , vaishali nagar jaipur , xxxxxxxxx

when we type 'pooj' we are getting match as pooja tower but it is hard to find which pooja tower as there could be N number. Thus we need suggestions like

Pooja tower , Gopalpura mode , jaipur

This way user will get an idea of place with the address.

Note. Tried mergeing two column into one with comma seprated but getting suggestions like

pooja  
pooja tower  
pooja tower gopalpura  
pooja tower gopalpura mode  
pooja tower gopalpura mode jaipur

Thanks for the help

---

<div class="post-metadata">

**Author:** ![joemcelroy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joemcelroy/32/103757_2.png) [@joemcelroy](https://discuss.elastic.co/u/joemcelroy)\
**Post date:** [March 16, 2022, 12:30pm UTC](https://discuss.elastic.co/t/getting-search-suggestion-from-secondary-field/299846/2 "2022-03-16T12:30:18Z")

</div>

hey @Himanshu_Jain3

Are you using Search UI autocomplete configuration? If so, could you share your configuration please?

What you request isn't possible with suggestions type but is possible with result suggestions type as the result suggestion is a full hit result so the change would be to adjust the secondary fields ( address and phone number) to show in the autocomplete.

Joe

---

<div class="post-metadata">

**Author:** ![kabilsharma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kabilsharma/32/100503_2.png) [@kabilsharma](https://discuss.elastic.co/u/kabilsharma)\
**Post date:** [March 17, 2022, 2:24am UTC](https://discuss.elastic.co/t/getting-search-suggestion-from-secondary-field/299846/3 "2022-03-17T02:24:53Z")

</div>

Hello Joseph

Thanks for the help. As I am new to this Elasticsearch World could you a better example base documentation other then results query suggestion documentation.

So I beleive that we can get search as you type suggestion from primary field with data from secondary field at suffix.

This way user will get more idea about primary field.

Please explain in laymen terms how we could achieve that. That would be a great help.

---

<div class="post-metadata">

**Author:** ![joemcelroy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joemcelroy/32/103757_2.png) [@joemcelroy](https://discuss.elastic.co/u/joemcelroy)\
**Post date:** [March 17, 2022, 12:18pm UTC](https://discuss.elastic.co/t/getting-search-suggestion-from-secondary-field/299846/4 "2022-03-17T12:18:04Z")

</div>

Hey,

So if you're using App Search and Search UI, this code below should be similar for SearchBox:

```auto
<SearchBox
 autocompleteMinimumCharacters={3}
  autocompleteResults={{
    linkTarget: "_blank",
    sectionTitle: "Results",
    titleField: "contactInformation", // the field just to present the result
    urlField: "nps_link",
    shouldTrackClickThrough: true,
    clickThroughTags: ["test"]
  }}
  autocompleteSuggestions={true}
  debounceLength={0}
/>

```

Now see the titleField property, thats the field you specify to display the result. In this example its title but you could create a new field (for example contactInformation) which contains "[Name] [Address] [Phone no]". That field contents will be present when matches in the autocomplete results are shown.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![kabilsharma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kabilsharma/32/100503_2.png) [@kabilsharma](https://discuss.elastic.co/u/kabilsharma)\
**Post date:** [March 25, 2022, 2:02am UTC](https://discuss.elastic.co/t/getting-search-suggestion-from-secondary-field/299846/5 "2022-03-25T02:02:36Z")

</div>

This is cool will try and update. Thanks for the Help.

---

<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:** [April 22, 2022, 2:02am UTC](https://discuss.elastic.co/t/getting-search-suggestion-from-secondary-field/299846/6 "2022-04-22T02:02:45Z")

</div>

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