Example #1
0
            public static SmlouvaSearchResult SearchRaw(QueryContainer query, int page, int pageSize, OrderResult order,
                                                        AggregationContainerDescriptor <Lib.Data.Smlouva> anyAggregation = null,
                                                        bool?platnyZaznam     = null, bool includeNeplatne = false, bool logError = true, bool fixQuery = true,
                                                        bool withHighlighting = false)
            {
                var result = new SmlouvaSearchResult()
                {
                    Page      = page,
                    PageSize  = pageSize,
                    OrigQuery = "",
                    Q         = "",
                    Order     = ((int)order).ToString()
                };

                ISearchResponse <Lib.Data.Smlouva> res = _coreSearch(query, page, pageSize, order, anyAggregation, platnyZaznam,
                                                                     includeNeplatne, logError, withHighlighting);


                if (res.IsValid == false && logError)
                {
                    Lib.ES.Manager.LogQueryError <Lib.Data.Smlouva>(res, query.ToString());
                }


                result.Total          = res?.Total ?? 0;
                result.IsValid        = res?.IsValid ?? false;
                result.ElasticResults = res;
                return(result);
            }
Example #2
0
            public static SmlouvaSearchResult SimpleSearch(string query, int page, int pageSize, OrderResult order,
                                                           AggregationContainerDescriptor <Lib.Data.Smlouva> anyAggregation = null,
                                                           bool?platnyZaznam     = null, bool includeNeplatne    = false, bool logError = true, bool fixQuery = true,
                                                           bool withHighlighting = false, bool exactNumOfResults = false)
            {
                var result = new SmlouvaSearchResult()
                {
                    Page      = page,
                    PageSize  = pageSize,
                    OrigQuery = query,
                    Q         = query,
                    Order     = ((int)order).ToString()
                };

                if (string.IsNullOrEmpty(query))
                {
                    result.ElasticResults = null;
                    result.IsValid        = false;
                    result.Total          = 0;
                    return(result);
                }

                Devmasters.DT.StopWatchEx sw = new Devmasters.DT.StopWatchEx();
                sw.Start();

                if (fixQuery)
                {
                    query    = Searching.Tools.FixInvalidQuery(query, irules, Searching.Tools.DefaultQueryOperators);
                    result.Q = query;
                }

                if (platnyZaznam.HasValue)
                {
                    query = Lib.Searching.Tools.ModifyQueryAND(query, "platnyZaznam:" + platnyZaznam.Value.ToString().ToLower());
                }


                ISearchResponse <Lib.Data.Smlouva> res =
                    _coreSearch(GetSimpleQuery(query), page, pageSize, order, anyAggregation, platnyZaznam,
                                includeNeplatne, logError, withHighlighting, exactNumOfResults);

                Data.Audit.Add(Data.Audit.Operations.Search, "", "", "Smlouva", res.IsValid ? "valid" : "invalid", query, null);

                if (res.IsValid == false && logError)
                {
                    Lib.ES.Manager.LogQueryError <Lib.Data.Smlouva>(res, query);
                }

                sw.Stop();

                result.ElapsedTime = sw.Elapsed;
                try
                {
                    result.Total = res?.Total ?? 0;
                }
                catch (Exception)
                {
                    result.Total = 0;
                }
                result.IsValid        = res?.IsValid ?? false;
                result.ElasticResults = res;
                return(result);
            }