Im Folgenden finden Sie meine Beispielsuchantwort mit 4 abgerufenen Ergebnissen.Wie filtern die ElasticSearch-Ergebnisse den Feldwert?
{ "took": 13, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 4, "max_score": 0.41753215, "hits": [ { "_index": "google_a804f89b-d32e-426a-a79a-ea83d65c98ea", "_type": "viz_dashlet", "_id": "/shared/Report_google_Shared", "_score": 0.41753215, "fields": { "lastModified": [ 1461738428007 ], "dir": [ "/shared" ], "filename": [ "Report_google_Shared" ] }, "highlight": { "filename": [ "Report_google_Shared" ] } }, { "_index": "google_a804f89b-d32e-426a-a79a-ea83d65c98ea", "_type": "viz_dashlet", "_id": "/shared/Report_Gmail_Shared", "_score": 0.41753215, "fields": { "lastModified": [ 1461738618676 ], "dir": [ "/shared" ], "filename": [ "Report_Gmail_Shared" ] }, "highlight": { "filename": [ "Report_Gmail_Shared" ] } }, { "_index": "google_a804f89b-d32e-426a-a79a-ea83d65c98ea", "_type": "viz_dashlet", "_id": "/private/hitesh/Report_Gmail_Private", "_score": 0.1883173, "fields": { "lastModified": [ 1461738629888 ], "dir": [ "/private/hitesh" ], "filename": [ "Report_Gmail_Private" ] }, "highlight": { "filename": [ "Report_Gmail_Private" ] } }, { "_index": "google_a804f89b-d32e-426a-a79a-ea83d65c98ea", "_type": "viz_dashlet", "_id": "/private/dholaria/Report_google_Private", "_score": 0.1883173, "fields": { "lastModified": [ 1461738451720 ], "dir": [ "/private/dholaria" ], "filename": [ "Report_google_Private" ] }, "highlight": { "filename": [ "Report_google_Private" ] } } ] } }
Jetzt möchte ich die obige Suchergebnisbasis den spezifischen "dir" Feldwert gemäß den folgenden Kriterien filtern.
Fügen Sie das Suchergebnis in der Antwort, wenn und nur wenn:
- Wenn "dir" gleich Feldwert entweder von: "/ shared" oder "/ private/hitesh"
- Else if " dir“Feldwert beginnt mit jedem von: "/ shared /" oder "/ private/hitesh /"
Wie kann ich die obige Funktionalität in Elasticsearch erreichen?
PS: Unten ist mein Beispiel Mapping.
{ "google_a804f89b-d32e-426a-a79a-ea83d65c98ea": { "mappings": { "viz_dashlet": { "properties": { "charts": { "type": "string", "index_analyzer": "report_index_analyzer", "search_analyzer": "report_search_analyzer", "fields": { "raw": { "type": "string", "index": "not_analyzed" } } }, "columnLabels": { "type": "string", "index_analyzer": "report_index_analyzer", "search_analyzer": "report_search_analyzer", "fields": { "raw": { "type": "string", "index": "not_analyzed" } } }, "columnNames": { "type": "string", "index_analyzer": "report_index_analyzer", "search_analyzer": "report_search_analyzer", "fields": { "raw": { "type": "string", "index": "not_analyzed" } } }, "creator": { "type": "string", "index_analyzer": "report_index_analyzer", "search_analyzer": "report_search_analyzer", "fields": { "raw": { "type": "string", "index": "not_analyzed" } } }, "dimensions": { "type": "string", "index_analyzer": "report_index_analyzer", "search_analyzer": "report_search_analyzer", "fields": { "raw": { "type": "string", "index": "not_analyzed" } } }, "dir": { "type": "string", "index_analyzer": "report_index_analyzer", "search_analyzer": "report_search_analyzer", "fields": { "raw": { "type": "string", "index": "not_analyzed" } } }, "expressions": { "type": "string", "index_analyzer": "report_index_analyzer", "search_analyzer": "report_search_analyzer", "fields": { "raw": { "type": "string", "index": "not_analyzed" } } }, "filename": { "type": "string", "index_analyzer": "whitespace_index", "search_analyzer": "whitespace_search", "fields": { "raw": { "type": "string", "index": "not_analyzed" } } }, "lastModified": { "type": "date", "format": "date_hour_minute_second" }, "measures": { "type": "string", "index_analyzer": "report_index_analyzer", "search_analyzer": "report_search_analyzer", "fields": { "raw": { "type": "string", "index": "not_analyzed" } } }, "promptFilters": { "type": "string", "index_analyzer": "report_index_analyzer", "search_analyzer": "report_search_analyzer", "fields": { "raw": { "type": "string", "index": "not_analyzed" } } } } } } } }
Was ist die Abbildung des 'dir' Feld? 'GET/birst_a804f89b-d32e-426a-a79a-ea83d65c98ea/viz_dashlet/_mapping/field/dir' –
@AndreiStefan Das Mapping wurde in der Frage selbst hinzugefügt. –