# Use of \_meta field in elasticsearch 2.4.1?

**URL:** <https://discuss.elastic.co/t/use-of--meta-field-in-elasticsearch-2-4-1/86506>\
**Category:** Elasticsearch\
**Created:** [May 20, 2017, 2:52am UTC](https://discuss.elastic.co/t/use-of--meta-field-in-elasticsearch-2-4-1/86506 "2017-05-20T02:52:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [May 20, 2017, 2:52am UTC](https://discuss.elastic.co/t/use-of--meta-field-in-elasticsearch-2-4-1/86506/1 "2017-05-20T02:52:44Z")

</div>

Hi,

In my scenario , i have two applications(i.e.A,B) both will push documents to ES .Normally in the slowlogs we can able to get the

`[2016-03-23 06:43:47,231][DEBUG][index.search.slowlog.fetch] took[5.8ms], took_millis[5], types[talk], stats[], search_type[QUERY_THEN_FETCH], total_shards[5], source[{"query":{"match":{"tags":"Java"}}}], extra_source[]`

Suppose if i had enabled the \_meta field in ES , is it possible to reflect the field in slowlogs like this?

`[2016-03-23 06:43:47,231][DEBUG]`[Application]`[index.search.slowlog.fetch] took[5.8ms], took_millis[5], types[talk], stats[], search_type[QUERY_THEN_FETCH], total_shards[5], source[{"query":{"match":{"tags":"Java"}}}], extra_source[]`

I want to know whether the document pushed from application A or B? Is it possible in ES?

I went to the documentation of [\_meta field](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-meta-field.html) but didnt get clear info on that , if possible please put some light on that?

Doc also says that this field is not used by Elasticsearch. What does this stmt mean , means I can't able to do perform any operations on this field?

Thanks

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [May 26, 2017, 10:13am UTC](https://discuss.elastic.co/t/use-of--meta-field-in-elasticsearch-2-4-1/86506/2 "2017-05-26T10:13:40Z")

</div>

Hi @Yaswanth,

the `_meta` field is defined per field in the mapping, not per request. The main use case is frameworks that help you map your domain objects to Elasticsearch document types.

However, you could use [stats groups](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search.html#stats-groups) for that. E.g.:

```auto
GET /_search
{
    "query": {
        "match_all": {}
    },
    "stats" : ["myapplication"]
}

```

This will show up in the slow query log as:

```auto
[2017-05-26 12:12:08,011][INFO][index.search.slowlog.fetch] [Elven] [old_books][3] took[219.7micros], took_millis[0], types[], stats[myapplication], search_type[QUERY_THEN_FETCH], total_shards[5], source[{"query":{"match_all":{}},"stats":["myapplication"]}], extra_source[], 

```

(this specific example is created by Elasticsearch 2.4.5 but it should look similar with all versions of Elasticsearch).

Daniel

---

<div class="post-metadata">

**Author:** ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)\
**Post date:** [May 28, 2017, 2:48pm UTC](https://discuss.elastic.co/t/use-of--meta-field-in-elasticsearch-2-4-1/86506/3 "2017-05-28T14:48:58Z")

</div>

Thanks @danielmitterdorfer

SO, it is clear that i can't able to use `_meta` for my usecase rather i can use `stats groups` which i can able to track in my slowlog source field.

In your answer you had mentioned [quote="danielmitterdorfer, post:2, topic:86506"]  
The main use case is frameworks that help you map your domain objects to Elasticsearch document types  
[/quote]

Can you please explain the above sentence with an example?

Also in the [\_meta documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-meta-field.html) they had mentioned `_meta` is used on mapping type rather than per field?

Thanks

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [June 19, 2017, 6:48am UTC](https://discuss.elastic.co/t/use-of--meta-field-in-elasticsearch-2-4-1/86506/4 "2017-06-19T06:48:58Z")

</div>

Hi @Yaswanth,

> [@Yaswanth](#):
>
> Can you please explain the above sentence with an example?

Here is an example from Spring Data with a [`Person`](https://github.com/SpringDataElasticsearchDevs/spring-data-elasticsearch-sample-application/blob/master/src/main/java/org/springframework/data/elasticsearch/entities/Person.java) class in Java that is mapped. to the index `person` with type `user`in Elasticsearch. I did not check whether it is really implemented as I said in Spring Data but Spring Data could populate the `_meta` field as follows:

```auto
PUT person
{
  "mappings": {
    "user": {
      "_meta": { 
        "class": "org.springframework.data.elasticsearch.entities.Person"
      }
    }
  }
}

```

By reading the `_meta` field, Spring Data can infer how to map a corresponding document in Elasticsearch to an instance of `org.springframework.data.elasticsearch.entities.Person`. I hope that clarifies it.

Daniel

---

<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 17, 2017, 6:49am UTC](https://discuss.elastic.co/t/use-of--meta-field-in-elasticsearch-2-4-1/86506/5 "2017-07-17T06:49:10Z")

</div>

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