# Query array of keyword responce different in source and docfields

**URL:** <https://discuss.elastic.co/t/query-array-of-keyword-responce-different-in-source-and-docfields/302389>\
**Category:** Elasticsearch\
**Created:** [April 14, 2022, 3:34am UTC](https://discuss.elastic.co/t/query-array-of-keyword-responce-different-in-source-and-docfields/302389 "2022-04-14T03:34:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![waitingF](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waitingf/32/104378_2.png) [@waitingF](https://discuss.elastic.co/u/waitingF)\
**Post date:** [April 14, 2022, 3:34am UTC](https://discuss.elastic.co/t/query-array-of-keyword-responce-different-in-source-and-docfields/302389/1 "2022-04-14T03:34:43Z")

</div>

I have an mapping of keyword field, like below

```auto
PUT test-map
{  
  "mappings": {    
    "properties": {      
      "field": {        
        "type": "keyword"      
      }    
    }  
  }
}

```

And I post a doc:

```auto
POST test-map/_doc
{
  "field": ["foo", "bar"]
}

```

Then query the doc like:

```auto
GET test-map/_search
{
  "docvalue_fields": ["field"]
}

```

which responce in different in source field and docvalue field:  
In the source, the order of value is the insertion order, but the order of docvlaue fields is order by alphabet

```auto
    "hits" : [
      {
        "_index" : "test-map",
        "_type" : "_doc",
        "_id" : "IFwbJoABrlDVcd2g6k0w",
        "_score" : 1.0,
        "_source" : {
          "field" : [
            "foo",
            "bar"
          ]
        },
        "fields" : {
          "field" : [
            "bar",
            "foo"
          ]
        }
      }
    ]

```

I wonder is this a bug? and why is it different?

---

<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 12, 2022, 3:35am UTC](https://discuss.elastic.co/t/query-array-of-keyword-responce-different-in-source-and-docfields/302389/2 "2022-05-12T03:35:43Z")

</div>

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