0

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.

4

1 回答 1

1

这不是元字段的用途。映射中配置的元字段不是搜索响应的一部分,它们只包含索引元数据中的附加信息,仅此而已 - 关于元字段,与查询(甚至与您的数据)的交互为零。

此外,您对带有下划线的字段的假设是错误的。它们被视为常规字段。

于 2017-06-28T09:36:58.547 回答