]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: es: add support for searchable storage_class field
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 24 Jan 2019 03:27:54 +0000 (19:27 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 25 Jan 2019 23:47:11 +0000 (15:47 -0800)
Note that this will not add field to existing index field mapping.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_sync_module_es.cc
src/rgw/rgw_sync_module_es_rest.cc

index 5cea97c3525ec1615e8ea31cdbb256244c02b584..fce97658ebb2f560cde5226f1f5df7ec0e85b600 100644 (file)
@@ -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");
index 38da69fadd8b414c31fffa37de962643fd34cd53..204adb43adc05fdec4d0d67b906270d440955b32 100644 (file)
@@ -23,6 +23,7 @@ struct es_index_obj_response {
     ceph::real_time mtime;
     string etag;
     string content_type;
+    string storage_class;
     map<string, string> custom_str;
     map<string, int64_t> custom_int;
     map<string, string> 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<string> > 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) {