]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_es_main.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
8 #include "global/global_init.h"
9 #include "global/global_context.h"
11 #include "common/ceph_argparse.h"
12 #include "common/ceph_json.h"
13 #include "rgw_es_query.h"
16 int main(int argc
, char *argv
[])
18 vector
<const char*> args
;
19 argv_to_vec(argc
, (const char **)argv
, args
);
21 auto cct
= global_init(NULL
, args
, CEPH_ENTITY_TYPE_CLIENT
,
22 CODE_ENVIRONMENT_UTILITY
, 0);
24 common_init_finish(g_ceph_context
);
34 ESQueryCompiler
es_query(expr
, nullptr, "x-amz-meta-");
36 map
<string
, string
, ltstr_nocase
> aliases
= { { "key", "name" },
37 { "etag", "meta.etag" },
38 { "size", "meta.size" },
39 { "mtime", "meta.mtime" },
40 { "lastmodified", "meta.mtime" },
41 { "contenttype", "meta.contenttype" },
43 es_query
.set_field_aliases(&aliases
);
45 map
<string
, ESEntityTypeMap::EntityType
> generic_map
= { {"bucket", ESEntityTypeMap::ES_ENTITY_STR
},
46 {"name", ESEntityTypeMap::ES_ENTITY_STR
},
47 {"instance", ESEntityTypeMap::ES_ENTITY_STR
},
48 {"meta.etag", ESEntityTypeMap::ES_ENTITY_STR
},
49 {"meta.contenttype", ESEntityTypeMap::ES_ENTITY_STR
},
50 {"meta.mtime", ESEntityTypeMap::ES_ENTITY_DATE
},
51 {"meta.size", ESEntityTypeMap::ES_ENTITY_INT
} };
52 ESEntityTypeMap
gm(generic_map
);
53 es_query
.set_generic_type_map(&gm
);
55 map
<string
, ESEntityTypeMap::EntityType
> custom_map
= { {"str", ESEntityTypeMap::ES_ENTITY_STR
},
56 {"int", ESEntityTypeMap::ES_ENTITY_INT
},
57 {"date", ESEntityTypeMap::ES_ENTITY_DATE
} };
58 ESEntityTypeMap
em(custom_map
);
59 es_query
.set_custom_type_map(&em
);
63 bool valid
= es_query
.compile(&err
);
65 cout
<< "failed to compile query: " << err
<< std::endl
;
70 encode_json("root", es_query
, &f
);