From d9978ffeacde495d277f5bc760e1593927740bae Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 23 Jan 2019 19:27:54 -0800 Subject: [PATCH] rgw: es: add support for searchable storage_class field Note that this will not add field to existing index field mapping. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_sync_module_es.cc | 1 + src/rgw/rgw_sync_module_es_rest.cc | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_sync_module_es.cc b/src/rgw/rgw_sync_module_es.cc index 5cea97c3525ec..fce97658ebb2f 100644 --- a/src/rgw/rgw_sync_module_es.cc +++ b/src/rgw/rgw_sync_module_es.cc @@ -307,6 +307,7 @@ struct es_index_mappings { encode_json("content_encoding", es_dump_type(string_type), f); encode_json("content_language", es_dump_type(string_type), f); encode_json("content_type", es_dump_type(string_type), f); + encode_json("storage_class", es_dump_type(string_type), f); encode_json("etag", es_dump_type(string_type), f); encode_json("expires", es_dump_type(string_type), f); f->open_object_section("mtime"); diff --git a/src/rgw/rgw_sync_module_es_rest.cc b/src/rgw/rgw_sync_module_es_rest.cc index 38da69fadd8b4..204adb43adc05 100644 --- a/src/rgw/rgw_sync_module_es_rest.cc +++ b/src/rgw/rgw_sync_module_es_rest.cc @@ -23,6 +23,7 @@ struct es_index_obj_response { ceph::real_time mtime; string etag; string content_type; + string storage_class; map custom_str; map custom_int; map custom_date; @@ -44,6 +45,7 @@ struct es_index_obj_response { parse_time(mtime_str.c_str(), &mtime); JSONDecoder::decode_json("etag", etag, obj); JSONDecoder::decode_json("content_type", content_type, obj); + JSONDecoder::decode_json("storage_class", storage_class, obj); list<_custom_entry > str_entries; JSONDecoder::decode_json("custom-string", str_entries, obj); for (auto& e : str_entries) { @@ -185,6 +187,8 @@ void RGWMetadataSearchOp::execute() { "last_modified", "meta.mtime" }, { "contenttype", "meta.content_type" }, { "content_type", "meta.content_type" }, + { "storageclass", "meta.storage_class" }, + { "storage_class", "meta.storage_class" }, }; es_query.set_field_aliases(&aliases); @@ -195,7 +199,8 @@ void RGWMetadataSearchOp::execute() {"meta.etag", ESEntityTypeMap::ES_ENTITY_STR}, {"meta.content_type", ESEntityTypeMap::ES_ENTITY_STR}, {"meta.mtime", ESEntityTypeMap::ES_ENTITY_DATE}, - {"meta.size", ESEntityTypeMap::ES_ENTITY_INT} }; + {"meta.size", ESEntityTypeMap::ES_ENTITY_INT}, + {"meta.storage_class", ESEntityTypeMap::ES_ENTITY_STR} }; ESEntityTypeMap gm(generic_map); es_query.set_generic_type_map(&gm); @@ -336,6 +341,7 @@ public: s->formatter->dump_int("Size", e.meta.size); s->formatter->dump_format("ETag", "\"%s\"", e.meta.etag.c_str()); s->formatter->dump_string("ContentType", e.meta.content_type.c_str()); + s->formatter->dump_string("StorageClass", e.meta.storage_class.c_str()); dump_owner(s, e.owner.get_id(), e.owner.get_display_name()); s->formatter->open_array_section("CustomMetadata"); for (auto& m : e.meta.custom_str) { -- 2.39.5