]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: define es index mapping
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 17 Mar 2017 00:02:17 +0000 (17:02 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 30 May 2017 20:18:58 +0000 (13:18 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_sync_module_es.cc

index d500e9b937bd32a4da3183d5e216407c5b242fa0..002cffd769b18279cde4f8402b8da695edf4ff8b 100644 (file)
@@ -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();
     }