From: Yehuda Sadeh Date: Fri, 31 Mar 2017 00:11:02 +0000 (-0700) Subject: rgw: es: limit indexing to only configured user meta X-Git-Tag: ses5-milestone6~9^2~3^2~44 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e4e6e1e51cf7a541477afddf1ac77b5a9c1da30b;p=ceph.git rgw: es: limit indexing to only configured user meta only metadata keys that are configured on user's bucket are allowed to be indexed. Also, use the type of meta that was configured. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_sync_module_es.cc b/src/rgw/rgw_sync_module_es.cc index fd0df360cb54..b80f5ba1bbd7 100644 --- a/src/rgw/rgw_sync_module_es.cc +++ b/src/rgw/rgw_sync_module_es.cc @@ -8,6 +8,7 @@ #include "rgw_rest_conn.h" #include "rgw_cr_rest.h" #include "rgw_op.h" +#include "rgw_es_query.h" #define dout_subsys ceph_subsys_rgw @@ -157,9 +158,51 @@ struct es_obj_metadata { for (auto i : out_attrs) { ::encode_json(i.first.c_str(), i.second, f); } - if (!custom_meta.empty()) { + map custom_str; + map custom_int; + map custom_date; + + for (auto i : custom_meta) { + auto config = bucket_info.mdsearch_config.find(i.first); + if (config == bucket_info.mdsearch_config.end()) { + ldout(cct, 20) << "custom meta entry key=" << i.first << " not found in bucket mdsearch config: " << bucket_info.mdsearch_config << dendl; + continue; + } + switch (config->second) { + case ESEntityTypeMap::ES_ENTITY_DATE: + custom_date[i.first] = i.second; + break; + case ESEntityTypeMap::ES_ENTITY_INT: + custom_int[i.first] = i.second; + break; + default: + custom_str[i.first] = i.second; + } + } + + if (!custom_str.empty()) { f->open_array_section("custom-string"); - for (auto i : custom_meta) { + for (auto i : custom_str) { + 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(); + } + if (!custom_int.empty()) { + f->open_array_section("custom-int"); + for (auto i : custom_int) { + 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(); + } + if (!custom_date.empty()) { + f->open_array_section("custom-date"); + for (auto i : custom_date) { f->open_object_section("entity"); ::encode_json("name", i.first.c_str(), f); ::encode_json("value", i.second, f);