# Search-as-you-type with bool query and suggestions

**URL:** <https://discuss.elastic.co/t/search-as-you-type-with-bool-query-and-suggestions/73057>\
**Category:** Elasticsearch\
**Created:** [January 27, 2017, 7:22pm UTC](https://discuss.elastic.co/t/search-as-you-type-with-bool-query-and-suggestions/73057 "2017-01-27T19:22:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![phlegx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/phlegx/32/14979_2.png) [@phlegx](https://discuss.elastic.co/u/phlegx)\
**Post date:** [January 27, 2017, 7:22pm UTC](https://discuss.elastic.co/t/search-as-you-type-with-bool-query-and-suggestions/73057/1 "2017-01-27T19:22:35Z")

</div>

Hi! I'm new in elasticsearch and I want to try a search-as-you-type application with bool query and suggestions. I use Ruby on Rails. Here my mapping:

```
  settings do
    mappings dynamic: 'false' do
      indexes :locale, type: :keyword
      indexes :search, type: :completion
      indexes :configuration, type: :nested do
        indexes :data, dynamic: 'true' do
        end
      end
    end
  end

```

Here my search query:

```
{
query: {
    bool: {
        must: [
        {
            constant_score: {
                filter: {
                    term: {
                        locale: 'en'
                    }
                }
            }
        }, {
            nested: {
                path: 'configuration',
                query: {
                    constant_score: {
                        filter: {
                            terms: {
                                'configuration.data.first': ['s']
                            }
                        }
                    }
                }
            }
        }, {
            nested: {
                path: 'configuration',
                query: {
                    constant_score: {
                        filter: {
                            terms: {
                                'configuration.data.second': ['p']
                            }
                        }
                    }
                }
            }
        }
        ]
    }
},
suggest: {
    suggestions: {
        text: 'hello t',
        completion: {
            field: 'search'
        }
    }
}

```

Is it possible to use suggest and query at the same time? I want to get suggests on the subset queried by locale and configuration. Is this the right way to accomplish what I want to do or not? I know about context suggester but I don't know how to access nested fields.

---

<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:** [February 24, 2017, 7:22pm UTC](https://discuss.elastic.co/t/search-as-you-type-with-bool-query-and-suggestions/73057/2 "2017-02-24T19:22:35Z")

</div>

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