# Return matches only for "prefix" query

**URL:** https://discuss.elastic.co/t/return-matches-only-for-prefix-query/38741
**Category:** Elasticsearch
**Created:** [January 8, 2016, 3:19pm UTC](https://discuss.elastic.co/t/return-matches-only-for-prefix-query/38741 "2016-01-08T15:19:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Benjamin\_Gathmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_gathmann/32/7561_2.png) [@Benjamin\_Gathmann](https://discuss.elastic.co/u/Benjamin_Gathmann)
#### Post date: [January 8, 2016, 3:19pm UTC](https://discuss.elastic.co/t/return-matches-only-for-prefix-query/38741/1 "2016-01-08T15:19:47Z")

</div>

I have documents that contain e.g. 100 or more different IP addresses, e.g. like this:

```
{"httpcalls": [
     {"dstip":"192.199.2.103"},
     {"dstip":"286.199.2.100"},
     ..... many more
]}

```

Now let's say I run a "prefix" query to look for IP addresses that start with "286.199", but I only want Elasticsearch to return the "dstip" entries that match.  
Is there a way to achieve this?

From what I read so far, I understand that I can only choose between returning ALL "dstip" fields from the documents that matched, or none at all.

The first option means that I receive e.g. 10,000 matching documents with 200 IPs each, i.e. 2,000,000 "dstip" entries. Too much data for me 😉

---

<div class="post-metadata">

### Author: ![Benjamin\_Gathmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_gathmann/32/7561_2.png) [@Benjamin\_Gathmann](https://discuss.elastic.co/u/Benjamin_Gathmann)
#### Post date: [January 11, 2016, 3:08pm UTC](https://discuss.elastic.co/t/return-matches-only-for-prefix-query/38741/2 "2016-01-11T15:08:04Z")

</div>

I saw that **inner hits** may be a partial solution for my problem:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-inner-hits.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-inner-hits.html)

But if anybody else has advice, please let me know!

---

<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: [July 5, 2017, 11:25pm UTC](https://discuss.elastic.co/t/return-matches-only-for-prefix-query/38741/3 "2017-07-05T23:25:24Z")

</div>


