# Problem with Fields in Search API

**URL:** <https://discuss.elastic.co/t/problem-with-fields-in-search-api/11269>\
**Category:** Elasticsearch\
**Created:** [March 22, 2013, 7:32pm UTC](https://discuss.elastic.co/t/problem-with-fields-in-search-api/11269 "2013-03-22T19:32:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frank\_Budinsky](https://avatars.discourse-cdn.com/v4/letter/f/919ad9/32.png) [@Frank\_Budinsky](https://discuss.elastic.co/u/Frank_Budinsky)\
**Post date:** [March 22, 2013, 7:32pm UTC](https://discuss.elastic.co/t/problem-with-fields-in-search-api/11269/1 "2013-03-22T19:32:42Z")

</div>

Hi,

I'm trying to run a query with a specific field selection like this:

{  
"fields": ["appointments.time"],  
"query": {  
"match": { "appointments.name" : "John" }  
}  
}

The document I'm querying looks like this:

{  
"appointments": [  
{  
"name": "John",  
"time": "2013-03-14T12:30:00Z"  
},  
{  
"name": "Katherine",  
"time": "2013-03-20T09:45:00Z"  
}  
]  
}

If the mapping for appointments.time has store set to yes, this doesn't seem to return any fields. My mapping looks like this:

{  
"properties": {  
'appointments.time': {  
'store': 'yes',  
'type': 'date',  
'format': 'dateOptionalTime'  
},  
}  
}

If I change store to no, then it works as expected.

Is this a bug, or am I doing something wrong (I'm using version 0.20.5)?

Btw, as an aside, is there any way to ask it to return only the fields in the list entries that matched the query?

Thanks,  
Frank.

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [March 25, 2013, 10:17pm UTC](https://discuss.elastic.co/t/problem-with-fields-in-search-api/11269/2 "2013-03-25T22:17:39Z")

</div>

It's not a bug, it's Elasticsearch getting confused between a field with  
the name "appointments.time" on the top level and a field "time" inside the  
field "appointment". I am not sure if this explanation makes sense, but you  
can fix the issue by specifying mapping like this:

```
        "properties": { 
            "appointments"{
                "properties": {
                    "time": { 
                        "store": "yes", 
                        "type": "date", 
                        "format": "dateOptionalTime"
                    }                    
                }
            }
        } 

```

On Friday, March 22, 2013 3:32:43 PM UTC-4, Frank Budinsky wrote:

> Hi,
> 
> I'm trying to run a query with a specific field selection like this:
> 
> {  
> "fields": ["appointments.time"],  
> "query": {  
> "match": { "appointments.name" : "John" }  
> }  
> }
> 
> The document I'm querying looks like this:
> 
> {  
> "appointments": [  
> {  
> "name": "John",  
> "time": "2013-03-14T12:30:00Z"  
> },  
> {  
> "name": "Katherine",  
> "time": "2013-03-20T09:45:00Z"  
> }  
> ]  
> }
> 
> If the mapping for appointments.time has store set to yes, this doesn't  
> seem  
> to return any fields. My mapping looks like this:
> 
> {  
> "properties": {  
> 'appointments.time': {  
> 'store': 'yes',  
> 'type': 'date',  
> 'format': 'dateOptionalTime'  
> },  
> }  
> }
> 
> If I change store to no, then it works as expected.
> 
> Is this a bug, or am I doing something wrong (I'm using version 0.20.5)?
> 
> Btw, as an aside, is there any way to ask it to return only the fields in  
> the list entries that matched the query?
> 
> Thanks,  
> Frank.
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Problem-with-Fields-in-Search-API-tp4032206.html](http://elasticsearch-users.115913.n3.nabble.com/Problem-with-Fields-in-Search-API-tp4032206.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:44am UTC](https://discuss.elastic.co/t/problem-with-fields-in-search-api/11269/3 "2017-07-06T02:44:32Z")

</div>


