Use of _meta field in elasticsearch 2.4.1?

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 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

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 for that. E.g.:

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

This will show up in the slow query log as:

[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

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 they had mentioned _meta is used on mapping type rather than per field?

Thanks

Hi @Yaswanth,

Here is an example from Spring Data with a Person class in Java that is mapped. to the index person with type userin 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:

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

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