]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: es: generic keys are not case sensitive
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 7 Apr 2017 23:34:35 +0000 (16:34 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 30 May 2017 20:26:53 +0000 (13:26 -0700)
make map case insensitive, and explicitly define all generic keys
so that they can be forced to be lower case.

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

index 89b2e0665fff5206c4fe243d98ece1fba2e70465..78b2865ed3327d8186f4c4ac9829f50e9cc6a7dc 100644 (file)
@@ -34,7 +34,7 @@ int main(int argc, char *argv[])
 
   ESQueryCompiler es_query(expr, nullptr, "x-amz-meta-");
 
-  map<string, string> aliases = { { "key", "name" },
+  map<string, string, ltstr_nocase> aliases = { { "key", "name" },
                                   { "etag", "meta.etag" },
                                   { "size", "meta.size" },
                                   { "mtime", "meta.mtime" },
index 52711be8609a10416da27aa9f83de2740fb6e30d..4375d93251cf609fdb3e3324918f3796f9749c24 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef CEPH_RGW_ES_QUERY_H
 #define CEPH_RGW_ES_QUERY_H
 
+#include "rgw_string.h"
+
 class ESQueryStack {
   list<string> l;
   list<string>::iterator iter;
@@ -100,7 +102,7 @@ class ESQueryCompiler {
   ESEntityTypeMap *generic_type_map{nullptr};
   ESEntityTypeMap *custom_type_map{nullptr};
 
-  map<string, string> *field_aliases;
+  map<string, string, ltstr_nocase> *field_aliases;
   set<string> *restricted_fields;
 
 public:
@@ -131,7 +133,7 @@ public:
     return custom_type_map;
   }
 
-  void set_field_aliases(map<string, string> *fa) {
+  void set_field_aliases(map<string, string, ltstr_nocase> *fa) {
     field_aliases = fa;
   }
 
index db2183b3b42009e627b99fbabb47b5d80b216ed8..fec51040298ba5206de5577402bbe6ca4c0362b4 100644 (file)
@@ -162,7 +162,11 @@ void RGWMetadataSearchOp::execute()
 
   ESQueryCompiler es_query(expression, &conds, custom_prefix);
   
-  static map<string, string> aliases = { { "key", "name" },
+  static map<string, string, ltstr_nocase> aliases = {
+                                  { "bucket", "bucket" }, /* forces lowercase */
+                                  { "name", "name" },
+                                  { "key", "name" },
+                                  { "instance", "instance" },
                                   { "etag", "meta.etag" },
                                   { "size", "meta.size" },
                                   { "mtime", "meta.mtime" },