0
votes

Here is my mapping:

"mappings" : {
        "mytype" : {
            "_meta" : {
                "abs_parent_id" : {"type" : "integer"}
            },
            "properties" : {
                "title" : {"type" : "text"},
                "body" : {"type" : "text"},
                "tagnames" : {"type" : "text"},
                "nodetype" : {"type" : "text"},
                "author_id" : {"type" : "integer"},
                "author_name" : {"type" : "text"},
            }
        }
 }

I expect this to be the response when I do http://localhost:9200/myindex/mytype/_search?pretty:

"hits" : [
  {
    "_index" : "myindex",
    "_type" : "mytype",
    "_id" : "1",
    "_score" : 1.0,
    "_meta" : {
        "abs_parent_id" : null
      },
    "_source" : {
      "body" : "<p>Some statement</p>",
      "tagnames" : "tag",
      "title" : "question",
      "author_name" : "author",
      "node_type" : "question",
      "author_id" : 1000
    }
  },

But instead I get this as the response:

"hits" : [
  {
    "_index" : "myindex",
    "_type" : "mytype",
    "_id" : "1",
    "_score" : 1.0,
    "_source" : {
      "_meta" : {
        "abs_parent_id" : null
      },
      "body" : "<p>Some statement</p>",
      "tagnames" : "tag",
      "title" : "question",
      "author_name" : "author",
      "node_type" : "question",
      "author_id" : 1000
    }
  },

I need to have _meta field outside of _source so that I can disable _source on my queries which will save memory. Can anyone suggest a solution?

Aren't all fields which start with an underscore supposed to be outside of _source ?

Side note: I don't think this is relevant, but I'm doing all this with elasticsearch-py.

1

1 Answers

1
votes

this is not what meta fields are for. Meta fields configured in the mapping are not part of a search response, they just contain additional information in the index metadata and that's it - there is zero interaction with a query (or even with your data) with regards to meta fields.

Also your assumption regarding fields with underscores is wrong. They are treated as regular fields.