2 Unix SMB/CIFS implementation.
3 Main metadata server / Spotlight routines / ES backend
5 Copyright (C) Ralph Boehme 2019
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "rpc_server/mdssvc/mdssvc.h"
23 #include "rpc_server/mdssvc/mdssvc_es.h"
24 #include "rpc_server/mdssvc/es_parser.tab.h"
25 #include "rpc_server/mdssvc/es_mapping.h"
30 * $ ./spotlight2es '_kMDItemGroupId=="11"'
32 * $ ./spotlight2es '*=="test*"||kMDItemTextContent=="test*"'
36 int main(int argc
, char **argv
)
38 TALLOC_CTX
*mem_ctx
= NULL
;
39 json_t
*mappings
= NULL
;
40 json_error_t json_error
;
41 char *default_path
= NULL
;
42 const char *path
= NULL
;
43 const char *query_string
= NULL
;
44 const char *path_scope
= NULL
;
45 char *es_query
= NULL
;
49 printf("usage: %s QUERY\n", argv
[0]);
52 query_string
= argv
[1];
53 path_scope
= "/foo/bar";
55 lp_load_global(get_dyn_CONFIGFILE());
57 mem_ctx
= talloc_init("es_parser_test");
58 if (mem_ctx
== NULL
) {
62 default_path
= talloc_asprintf(mem_ctx
,
63 "%s/mdssvc/elasticsearch_mappings.json",
64 get_dyn_SAMBA_DATADIR());
65 if (default_path
== NULL
) {
70 path
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
79 mappings
= json_load_file(path
, 0, &json_error
);
80 if (mappings
== NULL
) {
81 DBG_ERR("Opening mapping file [%s] failed: %s\n",
82 path
, strerror(errno
));
87 ok
= map_spotlight_to_es_query(mem_ctx
,
92 printf("%s\n", ok
? es_query
: "*mapping failed*");
94 json_decref(mappings
);