From: Yehuda Sadeh Date: Fri, 17 Mar 2017 00:02:17 +0000 (-0700) Subject: rgw: define es index mapping X-Git-Tag: ses5-milestone6~9^2~3^2~68 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=49b27f4f90ea9c84d5a784c1d7dadf868c001d1d;p=ceph.git rgw: define es index mapping Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_sync_module_es.cc b/src/rgw/rgw_sync_module_es.cc index d500e9b937b..002cffd769b 100644 --- a/src/rgw/rgw_sync_module_es.cc +++ b/src/rgw/rgw_sync_module_es.cc @@ -20,6 +20,56 @@ static string es_get_obj_path(const RGWRealm& realm, const RGWBucketInfo& bucket return path; } +struct es_dump_type { + string type; + + es_dump_type(const string& t) : type(t) {} + + void dump(Formatter *f) const { + encode_json("type", type, f); + } +}; + +struct es_index_mappings { + void dump(Formatter *f) const { + f->open_object_section("mappings"); + f->open_object_section("object"); + f->open_object_section("properties"); + encode_json("bucket", es_dump_type("string"), f); + encode_json("name", es_dump_type("string"), f); + encode_json("instance", es_dump_type("string"), f); + f->open_object_section("meta"); + f->open_object_section("properties"); + encode_json("cache_control", es_dump_type("string"), f); + encode_json("content_disposition", es_dump_type("string"), f); + encode_json("content_encoding", es_dump_type("string"), f); + encode_json("content_language", es_dump_type("string"), f); + encode_json("content_type", es_dump_type("string"), f); + encode_json("etag", es_dump_type("string"), f); + encode_json("expires", es_dump_type("string"), f); + f->open_object_section("mtime"); + ::encode_json("type", "date", f); + ::encode_json("format", "strict_date_optional_time||epoch_millis", f); + f->close_section(); // mtime + encode_json("size", es_dump_type("long"), f); + f->open_object_section("custom-string"); + ::encode_json("type", "nested", f); + f->open_object_section("properties"); + f->open_object_section("name"); + ::encode_json("type", "string", f); + ::encode_json("index", "not_analyzed", f); + f->close_section(); // name + encode_json("value", es_dump_type("string"), f); + f->close_section(); // entry + f->close_section(); // custom-string + f->close_section(); // properties + f->close_section(); // meta + f->close_section(); // properties + f->close_section(); // object + f->close_section(); // mappings + } +}; + struct es_obj_metadata { CephContext *cct; RGWBucketInfo bucket_info; @@ -100,9 +150,12 @@ struct es_obj_metadata { ::encode_json(i.first.c_str(), i.second, f); } if (!custom_meta.empty()) { - f->open_object_section("custom"); + f->open_array_section("custom-string"); for (auto i : custom_meta) { - ::encode_json(i.first.c_str(), i.second, f); + f->open_object_section("entity"); + ::encode_json("name", i.first.c_str(), f); + ::encode_json("value", i.second, f); + f->close_section(); } f->close_section(); }