# Completion Suggester with Exact Starting Match and Whitespace Separated Words

**URL:** https://discuss.elastic.co/t/completion-suggester-with-exact-starting-match-and-whitespace-separated-words/82274
**Category:** Elasticsearch
**Created:** [April 13, 2017, 10:39am UTC](https://discuss.elastic.co/t/completion-suggester-with-exact-starting-match-and-whitespace-separated-words/82274 "2017-04-13T10:39:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![foobarbaz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/foobarbaz/32/15422_2.png) [@foobarbaz](https://discuss.elastic.co/u/foobarbaz)
#### Post date: [April 13, 2017, 10:39am UTC](https://discuss.elastic.co/t/completion-suggester-with-exact-starting-match-and-whitespace-separated-words/82274/1 "2017-04-13T10:39:58Z")

</div>

Following the completion suggester example from here: [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html)

Having trouble understanding how to index titles that have spaces. With the following index/mapping:

```
curl -XPUT 'localhost:9200/social?pretty' -H 'Content-Type: application/json' -d'
{
    "mappings": {
        "post" : {
            "properties" : {
                "suggest" : {
                    "type" : "completion"
                },
                "title" : {
                    "type": "keyword"
                }
            }
        }
    }
}
'

```

Adding a suggest with a space like so:

```
curl -XPOST 'localhost:9200/social/post' -H 'Content-Type: application/json' '{"suggest":{"input":"Alec Baldwin","weight":4}}'

```

Produces the following error:

```
`{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse"}],"type":"mapper_parsing_exception","reason":"failed to parse","caused_by":{"type":"json_e_o_f_exception","reason":"Unexpected end-of-input in VALUE_STRING\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@691d96c0; line: 1, column: 51]"}},"status":400}curl: (3) [globbing] unmatched close brace/bracket in column 16`

```

If the space is turned into a dash:

```
curl -XPOST 'localhost:9200/social/post' -H 'Content-Type: application/json' '{"suggest":{"input":"Alec-Baldwin","weight":4}}'

```

The suggest is successfully indexed:

```
{"_index":"social","_type":"post","_id":"AVtmxoQVIOBiOQZhZa8Y","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"created":true}

```

Have successfully indexed by splitting by space and indexing as an array like `{"suggest":{"input":["Alec", "Baldwin"],"weight":4}}` however when sending the completion suggester "Ale", this produces other matches like `young alec baldwin` which is undesired (these are programatically generated, too many to filter out manually); only interested in exact starting matches like `Alec Baldwin` or `Alec Baldwin Jr`.

Any insight would be greatly appreciated!

Best,  
Joshua

---

<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: [May 11, 2017, 10:49am UTC](https://discuss.elastic.co/t/completion-suggester-with-exact-starting-match-and-whitespace-separated-words/82274/2 "2017-05-11T10:49:02Z")

</div>

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