diff --git a/front/assets/js/app-search.js b/front/assets/js/app-search.js index 2a3cceb..dfea036 100644 --- a/front/assets/js/app-search.js +++ b/front/assets/js/app-search.js @@ -1,16 +1,18 @@ -const date = new Date(); +const dateS = new Date(); +const dateE = new Date(); var mapping = []; var fmapping = {}; var filter_operation = ["is", "is_not", "exists", "does_not_exists"] var filters_set = {} -date.setMinutes(date.getMinutes() - 15) +dateS.setMinutes(dateS.getMinutes() - 195) +dateE.setMinutes(dateE.getMinutes() - 180) $.datetimepicker.setLocale('ru'); -$('#datetimepicker_start').datetimepicker({timepicker: true, format:'Y-m-d H:i:s', step: 15, value:date}); +$('#datetimepicker_start').datetimepicker({timepicker: true, format:'Y-m-d H:i:s', step: 15, value:dateS}); $('#datetimepicker_end').datetimepicker({ timepicker: true, format:'Y-m-d H:i:s', step: 15, - value:new Date(), + value:dateE, onShow:function( ct ){ this.setOptions({ minDate:$('#datetimepicker_start').val()?$('#datetimepicker_start').val():false diff --git a/modules/router/methods.go b/modules/router/methods.go index 1e5c8d8..9210937 100644 --- a/modules/router/methods.go +++ b/modules/router/methods.go @@ -236,6 +236,7 @@ func (rt *Router) getIndexGroups(cluster string) ([]indexGroup, error) { return nil, err } err = json.Unmarshal(response, &igs) + fmt.Printf("%v\n", igs) if err != nil { return nil, err } @@ -244,8 +245,9 @@ func (rt *Router) getIndexGroups(cluster string) ([]indexGroup, error) { n.Index = match[1] + "-*" igresp = append(igresp, n) } - - return igresp, nil + unique := removeDuplicates(igresp) + fmt.Printf("%v\n", unique) + return unique, nil } @@ -319,3 +321,18 @@ func allocateSpaceForFile(path string, size int64) { log.Fatal(err) } } + +func removeDuplicates(slice []indexGroup) []indexGroup { + // Create a map to store unique elements + seen := make(map[indexGroup]bool) + var result []indexGroup + + // Loop through the slice, adding elements to the map if they haven't been seen before + for _, val := range slice { + if _, ok := seen[val]; !ok { + seen[val] = true + result = append(result, val) + } + } + return result +} diff --git a/modules/router/router.go b/modules/router/router.go index f14f6d6..91f643a 100644 --- a/modules/router/router.go +++ b/modules/router/router.go @@ -653,7 +653,7 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) { for _, f := range request.Search.Filters { if f.Operation == "is" { - filters += `{ "match_phrase": {"` + f.Field + `":"` + f.Value + `" } },` + filters += `{ "wildcard": {"` + f.Field + `": {"value": "` + f.Value + `" } } },` } else if f.Operation == "exists" { filters += `{ "exists": {"field":"` + f.Field + `" } },` } else if f.Operation == "is_not" { @@ -684,7 +684,7 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) { query = fmt.Sprintf(`"query": { "bool": { "must": [ %s ],"filter": [ %s %s ], "should": [],"must_not": [ %s ] }}`, xql, tf, filters, must_not) full_query = fmt.Sprintf(`{"size": 500, %s, %s, %s, %s }`, sort, use_source, fields, query) - + fmt.Println(full_query) if request.Search.Count { _ = json.Unmarshal([]byte("{"+query+"}"), &req) cresponse, err := rt.doPost(host+request.Search.Index+"/_count", req, "Search") @@ -747,7 +747,7 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) { for _, f := range request.Search.Filters { if f.Operation == "is" { - filters += `{ "match_phrase": {"` + f.Field + `":"` + f.Value + `" } },` + filters += `{ "wildcard": {"` + f.Field + `": {"value": "` + f.Value + `" } } },` } else if f.Operation == "exists" { filters += `{ "exists": {"field":"` + f.Field + `" } },` } else if f.Operation == "is_not" { @@ -778,7 +778,6 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) { query = fmt.Sprintf(`"query": { "bool": { "must": [ %s ],"filter": [ %s %s ], "should": [],"must_not": [ %s ] }}`, xql, tf, filters, must_not) full_query = fmt.Sprintf(`{"size": 10000, %s, %s, %s, %s }`, sort, use_source, fields, query) - //fmt.Println(full_query) err = json.Unmarshal([]byte(full_query), &req) if err != nil { diff --git a/modules/version/version.go b/modules/version/version.go index 7d5df10..ad72379 100644 --- a/modules/version/version.go +++ b/modules/version/version.go @@ -13,4 +13,4 @@ package version -var Version = "extractor/v0.2.13" +var Version = "extractor/v0.2.14"