# Non-prefix-based Completion Suggester

**URL:** <https://discuss.elastic.co/t/non-prefix-based-completion-suggester/100443>\
**Category:** Elasticsearch\
**Created:** [September 14, 2017, 3:04am UTC](https://discuss.elastic.co/t/non-prefix-based-completion-suggester/100443 "2017-09-14T03:04:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![milenkozahovic](https://avatars.discourse-cdn.com/v4/letter/m/4491bb/32.png) [@milenkozahovic](https://discuss.elastic.co/u/milenkozahovic)\
**Post date:** [September 14, 2017, 3:04am UTC](https://discuss.elastic.co/t/non-prefix-based-completion-suggester/100443/1 "2017-09-14T03:04:02Z")

</div>

I have my mapping type as follows:

```
{
  "mappings": {
    "book": {
      "properties": {
        "title": {
          "type": "completion"
        }
      }
    }
  }
}

```

and index a data:

```
{"create": {"_index": "library", "_type": "book", "_id": 1}}
{"id": 1, "title": "C++ How to Program"}

```

my question is how do i get document with id 1 of type _book_ if my query is like this:

```
POST /library/book/_search
{
	"suggest": {
		"book-suggest": {
			"text": "program C++",
			"completion": {
				"field": "title"
			}
		}
	}
}
```

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [September 15, 2017, 7:53am UTC](https://discuss.elastic.co/t/non-prefix-based-completion-suggester/100443/2 "2017-09-15T07:53:23Z")

</div>

The completion suggester is prefix-based so partial match on the first and last term is not possible. Why do you need a `completion` field ? You could use a simple `text` field and use a `match` query instead ? This would be slower but much more flexible in terms of matching.

---

<div class="post-metadata">

**Author:** ![milenkozahovic](https://avatars.discourse-cdn.com/v4/letter/m/4491bb/32.png) [@milenkozahovic](https://discuss.elastic.co/u/milenkozahovic)\
**Post date:** [September 15, 2017, 7:55am UTC](https://discuss.elastic.co/t/non-prefix-based-completion-suggester/100443/3 "2017-09-15T07:55:06Z")

</div>

Need completion just for the speed. Thank you for the explanation.

---

<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:** [October 13, 2017, 7:55am UTC](https://discuss.elastic.co/t/non-prefix-based-completion-suggester/100443/4 "2017-10-13T07:55:16Z")

</div>

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