# Phrase\_prefix search issue with single character

**URL:** https://discuss.elastic.co/t/phrase-prefix-search-issue-with-single-character/208860
**Category:** Elasticsearch
**Created:** [November 21, 2019, 10:47am UTC](https://discuss.elastic.co/t/phrase-prefix-search-issue-with-single-character/208860 "2019-11-21T10:47:35Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![dipanshu\_sharma](https://avatars.discourse-cdn.com/v4/letter/d/77aa72/32.png) [@dipanshu\_sharma](https://discuss.elastic.co/u/dipanshu_sharma)
#### Post date: [November 21, 2019, 10:47am UTC](https://discuss.elastic.co/t/phrase-prefix-search-issue-with-single-character/208860/1 "2019-11-21T10:47:36Z")

</div>

I have a data like 'Dipanshu S', 'Mohit Sharma' and 'Mohit Shakya' in my database and when i do a ES search query like :-

> "multi\_match": {  
> "query": "Mohit S",  
> "type": "phrase\_prefix",  
> "fields": ["name", "nickname"]  
> }

It gives me correct result 'Mohit Sharma' and 'Mohit Shakya' as it returns results with exact matching of first term 'Mohit' and returning all words starting with 'S' but when i do same search with query

> "multi\_match": {  
> "query": "Dipanshu S",  
> "type": "phrase\_prefix",  
> "fields": ["name", "nickname"]  
> }

:"Dipanshu S" then it doesn't return any results because the word 'S' is not a word starting with character 'S' but its a complete word in itself in the data 'Dipanshu S'.

So how to manipulate query to get results with single character words?

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [November 21, 2019, 12:26pm UTC](https://discuss.elastic.co/t/phrase-prefix-search-issue-with-single-character/208860/2 "2019-11-21T12:26:40Z")

</div>

can you please share a fully reproducible example including index creation, document indexing and mapping...

This example works for me, so something in your setup seems to be different

```auto
DELETE test

PUT test/_doc/1?refresh
{
  "name" : "Dipanshu S"
}

GET test/_search
{
  "query": {
    "multi_match": {
      "query": "Dipanshu S",
      "type": "phrase_prefix",
      "fields": [
        "name"
      ]
    }
  }
}

```

Thanks!

--Alex

---

<div class="post-metadata">

### Author: ![dipanshu\_sharma](https://avatars.discourse-cdn.com/v4/letter/d/77aa72/32.png) [@dipanshu\_sharma](https://discuss.elastic.co/u/dipanshu_sharma)
#### Post date: [November 21, 2019, 1:11pm UTC](https://discuss.elastic.co/t/phrase-prefix-search-issue-with-single-character/208860/3 "2019-11-21T13:11:03Z")

</div>

I'm sharing my mappings and settings(analyzers) configs.  
Mapping:

> ```
> "name": {
> "type": "keyword",
> "fields": {
> "caseInsensitive": {
> "type": "text",
> "analyzer": "lowercase_keyword_analyzer"
> },
> "fulltext": {
> "type": "text",
> "analyzer": "english_standard_edgengram_analyzer",
> "search_analyzer": "english_standard_analyzer"
> }
> },
> "normalizer": "lowercase_normalizer"
> }
> 
> ```

Analyzer:

> ```
> "analyzer": {
> "numeric_edgengram_analyzer": {
> "filter": [
> "edgengram_filter"
> ],
> "char_filter": [
> "numeric_filter"
> ],
> "type": "custom",
> "tokenizer": "keyword"
> },
> "lowercase_keyword_analyzer": {
> "filter": [
> "lowercase"
> ],
> "type": "custom",
> "tokenizer": "keyword"
> },
> "numeric_keyword_analyzer": {
> "type": "custom",
> "char_filter": [
> "numeric_filter"
> ],
> "tokenizer": "keyword"
> },
> "english_standard_analyzer": {
> "filter": [
> "lowercase"
> ],
> "type": "keyword"
> },
> "english_standard_edgengram_analyzer": {
> "filter": [
> "lowercase",
> "edgengram_filter"
> ],
> "type": "custom",
> "tokenizer": "english_standard_tokenizer"
> }
> }
> 
> ```

And you can test with some different data like "Dipanshu S Gupta", "Dipanshu Sharma".

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [November 21, 2019, 2:09pm UTC](https://discuss.elastic.co/t/phrase-prefix-search-issue-with-single-character/208860/4 "2019-11-21T14:09:15Z")

</div>

can you please share the full commands of index creation + mapping in the console tools or in a curl compatible fashion? The above snippets means, everyone reading your ask for support needs to convert this in working snippets, which again is quite tedious.

Thank you!

---

<div class="post-metadata">

### Author: ![dipanshu\_sharma](https://avatars.discourse-cdn.com/v4/letter/d/77aa72/32.png) [@dipanshu\_sharma](https://discuss.elastic.co/u/dipanshu_sharma)
#### Post date: [November 21, 2019, 4:41pm UTC](https://discuss.elastic.co/t/phrase-prefix-search-issue-with-single-character/208860/5 "2019-11-21T16:41:45Z")

</div>

hey, it's little bit difficult for me to share that code but just wants to know that does the query "Dipanshu S" gives the result "Dipanshu S Sharma" ? I mean does the prefix "S" includes the result "Dipanshu S Sharma" as "S" is not a word starting from "S" but it's a complete word in itself. And did you got my question?

---

<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: [December 19, 2019, 4:41pm UTC](https://discuss.elastic.co/t/phrase-prefix-search-issue-with-single-character/208860/6 "2019-12-19T16:41:52Z")

</div>

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