# When I'm using prefix query it getting the documents where input string in middle also?

**URL:** <https://discuss.elastic.co/t/when-im-using-prefix-query-it-getting-the-documents-where-input-string-in-middle-also/192877>\
**Category:** Elasticsearch\
**Created:** [July 30, 2019, 11:04am UTC](https://discuss.elastic.co/t/when-im-using-prefix-query-it-getting-the-documents-where-input-string-in-middle-also/192877 "2019-07-30T11:04:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kartheek91](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@kartheek91](https://discuss.elastic.co/u/kartheek91)\
**Post date:** [July 30, 2019, 11:04am UTC](https://discuss.elastic.co/t/when-im-using-prefix-query-it-getting-the-documents-where-input-string-in-middle-also/192877/1 "2019-07-30T11:04:19Z")

</div>

I'm using Prefix query and here is the query

```
{
  "query": {
    "prefix": {
      "name": {
        "value": "asp"
      }
    }
  }
}

```

So I'm assuming that I need to get the documents based on the name property starting with "asp"

{  
"\_index" : "testindex",  
"\_type" : "doc",  
"\_id" : "123",  
"\_score" : 1.0,  
"\_source" : {  
"name" : "ASPIRIN"  
}  
},  
{  
"\_index" : "testindex",  
"\_type" : "doc",  
"\_id" : "223",  
"\_score" : 1.0,  
"\_source" : {  
"name" : "AMPHETAMINE ASPARTAT"  
}  
}  
}

---

<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:** [August 27, 2019, 11:04am UTC](https://discuss.elastic.co/t/when-im-using-prefix-query-it-getting-the-documents-where-input-string-in-middle-also/192877/2 "2019-08-27T11:04:22Z")

</div>

Closed on August 27, 2019, 11:04am UTC

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