# Context Suggestion query, but allow middle-text searching?

**URL:** <https://discuss.elastic.co/t/context-suggestion-query-but-allow-middle-text-searching/146773>\
**Category:** Elasticsearch\
**Created:** [August 30, 2018, 8:23pm UTC](https://discuss.elastic.co/t/context-suggestion-query-but-allow-middle-text-searching/146773 "2018-08-30T20:23:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RedactedProfile](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/redactedprofile/32/9426_2.png) [@RedactedProfile](https://discuss.elastic.co/u/RedactedProfile)\
**Post date:** [August 30, 2018, 8:23pm UTC](https://discuss.elastic.co/t/context-suggestion-query-but-allow-middle-text-searching/146773/1 "2018-08-30T20:23:45Z")

</div>

Hi there,

I'm trying to implement an auto-complete type-ahead search feature onto a documentation style website.

I love the speed of the suggestions, and this is definitely the feature I want to use, but, the problem is the "prefix" part of the query  
(currently using the official php library, but the query is all the same as if it were in json)

```
        [
            '_source' => [
                'title',
                'slug'
            ],
            'suggest' => [
                'page-titles' => [
                    'completion' => [
                        'field' => 'suggest',
                        'skip_duplicates' => true,
                        'fuzzy' => [
                            'fuzziness' => 2
                        ],
                        'contexts' => [
                            'product' => [$product],
                            'document' => [$document],
                            'version' => [$version]
                        ]
                    ],
                    'prefix' => $query
                ]
            ]
        ]

```

So this all works, it certainly lets you look up titles from the beginning and provides fine results.

The problem is that the titles end up being quite long, or, more importantly, more prolific words are used after the first word that a user might be so inclined to type instead (such as a related product name in my case)

So for example, if I have a page title like "Creating {related product name} profile packages", if they were to type in the search "profile", or "profile pac" or even the product name, this page wouldn't show up at all unless they knew to put "creating " first.

So, what should I do here?

**EDIT**

It's probably worth it to note that I do not have any control over the values of these titles, they are provided by other teams who have their own workflow and differing authoring styles. It's not realistic to implement or maintain some kind of list of these "prolific" words.

Basically a standard simple match query would suffice.

Also worth noting, that simply supplying the search query to the regex suggester for some reason also does not provide results for middle-text possibilities

---

<div class="post-metadata">

**Author:** ![RedactedProfile](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/redactedprofile/32/9426_2.png) [@RedactedProfile](https://discuss.elastic.co/u/RedactedProfile)\
**Post date:** [August 31, 2018, 5:28pm UTC](https://discuss.elastic.co/t/context-suggestion-query-but-allow-middle-text-searching/146773/2 "2018-08-31T17:28:16Z")

</div>

Ok so, considering the luke warm temperature of the response

is my only solution here to just run a standard regular query and not use the suggestion engine?

---

<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:** [September 28, 2018, 5:36pm UTC](https://discuss.elastic.co/t/context-suggestion-query-but-allow-middle-text-searching/146773/3 "2018-09-28T17:36:38Z")

</div>

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