]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_es_main.cc
5 #include "global/global_init.h"
6 #include "global/global_context.h"
8 #include "common/ceph_argparse.h"
9 #include "common/ceph_json.h"
10 #include "rgw_es_query.h"
14 int main(int argc
, char *argv
[])
16 vector
<const char*> args
;
17 argv_to_vec(argc
, (const char **)argv
, args
);
20 auto cct
= global_init(NULL
, args
, CEPH_ENTITY_TYPE_CLIENT
,
21 CODE_ENVIRONMENT_UTILITY
, 0);
23 common_init_finish(g_ceph_context
);
33 ESQueryCompiler
es_query(expr
, nullptr, "x-amz-meta-");
35 map
<string
, string
, ltstr_nocase
> aliases
= { { "key", "name" },
36 { "etag", "meta.etag" },
37 { "size", "meta.size" },
38 { "mtime", "meta.mtime" },
39 { "lastmodified", "meta.mtime" },
40 { "contenttype", "meta.contenttype" },
42 es_query
.set_field_aliases(&aliases
);
44 map
<string
, ESEntityTypeMap::EntityType
> generic_map
= { {"bucket", ESEntityTypeMap::ES_ENTITY_STR
},
45 {"name", ESEntityTypeMap::ES_ENTITY_STR
},
46 {"instance", ESEntityTypeMap::ES_ENTITY_STR
},
47 {"meta.etag", ESEntityTypeMap::ES_ENTITY_STR
},
48 {"meta.contenttype", ESEntityTypeMap::ES_ENTITY_STR
},
49 {"meta.mtime", ESEntityTypeMap::ES_ENTITY_DATE
},
50 {"meta.size", ESEntityTypeMap::ES_ENTITY_INT
} };
51 ESEntityTypeMap
gm(generic_map
);
52 es_query
.set_generic_type_map(&gm
);
54 map
<string
, ESEntityTypeMap::EntityType
> custom_map
= { {"str", ESEntityTypeMap::ES_ENTITY_STR
},
55 {"int", ESEntityTypeMap::ES_ENTITY_INT
},
56 {"date", ESEntityTypeMap::ES_ENTITY_DATE
} };
57 ESEntityTypeMap
em(custom_map
);
58 es_query
.set_custom_type_map(&em
);
62 bool valid
= es_query
.compile(&err
);
64 cout
<< "failed to compile query: " << err
<< std::endl
;
69 encode_json("root", es_query
, &f
);