elasticsearch

_meta field in elasticsearch usage?


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


Solution

  • You cannot use it for that (unless I'm misunderstanding the question).

    The _meta field in the template will be added to the index, not the documents. Also you'd need to have the attribute in the query, so that the slowlog could potentially use it (though there is no such concept as far as I know).

    To get a better understanding of _meta you might want to play through the following steps in Console (or translate them to cURL.

    PUT my_index
    {
      "mappings": {
        "user": {
          "_meta": { 
            "class": "MyApp::User",
            "version": {
              "min": "1.0",
              "max": "1.3"
            }
          }
        }
      }
    }
    
    GET my_index/_mapping
    
    PUT my_index/user/1
    {
      "foo": "bar"
    }
    
    GET my_index/_mapping
    
    GET my_index/user/1
    
    DELETE /my_index