public static DateTime GetLastDateTimeSerie(string databaseName, string collectionName, string timelineField, ElasticLowLevelClient lowLevalClient) { JObject json = new JObject( new JProperty("aggs", new JObject() { new JProperty("lastUpdated", new JObject() { new JProperty("max", new JObject() { new JProperty("field", timelineField) }) }) }) ); SearchRequestParameters param = new SearchRequestParameters(); param.SetQueryString("size", 0); var search = lowLevalClient.Search <StringResponse>(databaseName, collectionName, json.ToString(), param); if (search.Success) { var jsonResponse = JObject.Parse(search.Body); var longTicks = jsonResponse.SelectToken("aggregations.lastUpdated.value"); if (!string.IsNullOrEmpty(longTicks.ToString())) { return(DateTimeHelper.JavaTimeStampToDateTime(longTicks.Value <double>())); } } return(DateTime.MinValue); }
public ActionResult Index(SearchRequestParameters request) => RedirectToActionPermanent("Index", "Home", new { request.NsfwSetting, request.Page, request.Query, request.Reverse, request.Tags });
SearchRequestParameters SetRequestParameters( SearchRequestParameters searchRequestParameters, SearchRequest searchRequest) { if (string.Equals(searchRequest.SearchType, "count", StringComparison.OrdinalIgnoreCase)) searchRequestParameters.SearchType(SearchType.Count); return searchRequestParameters; }
///<summary>Specify which field to use for suggestions</summary> internal static SearchRequestParameters _SuggestField <T>( this SearchRequestParameters qs, Expression <Func <T, object> > suggest_field) where T : class { var p = (PropertyPathMarker)suggest_field; var _suggest_field = p; qs.AddQueryString("suggest_field", _suggest_field); return(qs); }
SearchRequestParameters SetRequestParameters( SearchRequestParameters searchRequestParameters, SearchRequest searchRequest) { if (string.Equals(searchRequest.SearchType, "count", StringComparison.OrdinalIgnoreCase)) { searchRequestParameters.SearchType(SearchType.Count); } return(searchRequestParameters); }
/// <summary> /// Prepares query parameters for /search /// </summary> /// <param name="x"></param> /// <param name="luceneQuery"></param> /// <param name="maxSize"></param> /// <returns></returns> protected SearchRequestParameters getSearchParameters(SearchRequestParameters x, string luceneQuery, int maxSize, bool scroll = false) { if (string.IsNullOrEmpty(luceneQuery)) { throw new ArgumentNullException("luceneQuery"); } if (maxSize > 0 && maxSize < int.MaxValue) { x = x.AddQueryString("size", maxSize.ToString()); } if (scroll) { x = x.AddQueryString("scroll", "1m"); } x = x.AddQueryString("q", luceneQuery); return(x); }
public async Task <IActionResult> Index(SearchRequestParameters request, CancellationToken cancellationToken) { var tags = new List <string>(); if (!string.IsNullOrWhiteSpace(request.Tags)) { tags = request.Tags.Split(',').Select(t => t.Trim()).ToList(); } var nsfwIndex = tags.FindIndex(t => string.Equals("nsfw", t, StringComparison.OrdinalIgnoreCase)); if (nsfwIndex > -1) { request.NsfwSetting = SearchNsfw.NsfwOnly; tags.RemoveAt(nsfwIndex); } SearchPromptsViewModel?result = await _mediator.Send( new SearchPromptsQuery { Page = request.Page ?? 1, Reverse = request.Reverse, Search = request.Query ?? string.Empty, Tags = tags, Nsfw = request.NsfwSetting, TagJoin = request.TagJoin, TagsFuzzy = !request.MatchExact }, cancellationToken); return(View(new SearchViewModel { Page = request.Page, Query = request.Query, Reverse = request.Reverse, Tags = request.Tags, NsfwSetting = request.NsfwSetting, SearchResult = result, MatchExact = request.MatchExact, TagJoin = request.TagJoin })); }
///<summary>Specify which field to use for suggestions</summary> internal static SearchRequestParameters _SuggestField <T>(this SearchRequestParameters qs, Expression <Func <T, object> > suggest_field) where T : class => qs.AddQueryString("suggest_field", (Field)suggest_field);
///<summary>A comma-separated list of fields to return as the docvalue representation of a field for each hit</summary> internal static SearchRequestParameters _DocvalueFields <T>(this SearchRequestParameters qs, IEnumerable <Expression <Func <T, object> > > docvalue_fields) where T : class => qs.AddQueryString("docvalue_fields", docvalue_fields.Select(e => (Field)e));
protected sealed override void RequestDefaults(SearchRequestParameters parameters) => TypedKeys();