--- /dev/null
+<samba:parameter name="elasticsearch:default_fields"
+ context="G"
+ type="string"
+ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+ <description>
+ <para>
+ Default attributes in Elasticsearch to query when receiving a Spotlight
+ query that searches in the special attribute "*". This is the default used
+ by macOS clients when searching from the Finder.
+ </para>
+ <para>
+ This option expects a list of Elasticsearch attributes separated by
+ comma where each attributes must be enclosed in double quotes.
+ </para>
+ </description>
+
+ <value type="default">"file.filename", "content"</value>
+ <value type="example">"foo", "bar"</value>
+</samba:parameter>
"must": [
{
"query_string": {
- "query": "samba*"
+ "query": "samba*",
+ "fields": ["file.filename", "content"]
}
}
]
"must": [
{
"query_string": {
- "query": "file.filename:x\\+x OR file.filename:x\\*x OR file.filename:x=x OR file.filename:x'x OR file.filename:x\\?x OR file.filename:x\\ x OR file.filename:x\\(x OR file.filename:x\\\"x OR file.filename:x\\\\x"
+ "query": "file.filename:x\\+x OR file.filename:x\\*x OR file.filename:x=x OR file.filename:x'x OR file.filename:x\\?x OR file.filename:x\\ x OR file.filename:x\\(x OR file.filename:x\\\"x OR file.filename:x\\\\x",
+ "fields": ["file.filename", "content"]
}
}
]
"must": [
{
"query_string": {
- "query": "*samba*"
+ "query": "*samba*",
+ "fields": ["file.filename", "content"]
}
}
]
" } ],\n" \
" \"must\": [ {\n" \
" \"query_string\": {\n" \
- " \"query\": \"%s\"\n" \
+ " \"query\": \"%s\",\n" \
+ " \"fields\": [%s]\n" \
" }\n" \
" } ]\n" \
" }\n" \
json_error_t json_error;
char *default_path = NULL;
const char *path = NULL;
+ const char *default_fields = "\"file.filename\", \"content\"";
mdssvc_es_ctx = talloc_zero(mdssvc_ctx, struct mdssvc_es_ctx);
if (mdssvc_es_ctx == NULL) {
}
TALLOC_FREE(default_path);
+ mdssvc_es_ctx->default_fields = lp_parm_const_string(GLOBAL_SECTION_SNUM,
+ "elasticsearch",
+ "default_fields",
+ default_fields);
+ if (mdssvc_es_ctx->default_fields == NULL) {
+ TALLOC_FREE(mdssvc_es_ctx);
+ return false;
+ }
+
mdssvc_ctx->backend_private = mdssvc_es_ctx;
return true;
}
return tevent_req_post(req, ev);
}
- elastic_query = talloc_asprintf(state,
- MDSSVC_ELASTIC_QUERY_TEMPLATE,
- s->from,
- s->size,
- MDSSVC_ELASTIC_SOURCES,
- s->slq->path_scope,
- s->es_query);
+ elastic_query = talloc_asprintf(
+ state,
+ MDSSVC_ELASTIC_QUERY_TEMPLATE,
+ s->from,
+ s->size,
+ MDSSVC_ELASTIC_SOURCES,
+ s->slq->path_scope,
+ s->es_query,
+ s->mds_es_ctx->mdssvc_es_ctx->default_fields);
if (tevent_req_nomem(elastic_query, req)) {
return tevent_req_post(req, ev);
}