public override List<SkinnyItem> GetItems(string indexName, string language, string templateFilter, string locationFilter, string fullTextQuery) { var searchParam = new DateRangeSearchParam { Ranges = Ranges, LocationIds = locationFilter, TemplateIds = templateFilter, FullTextQuery = fullTextQuery, Occurance = QueryOccurance.Must, Language = language, ShowAllVersions = false }; using (var searcher = new Searcher(indexName)) { return searcher.GetItemsInRange(searchParam); } }
protected void AddDateRangeQuery(BooleanQuery query, DateRangeSearchParam.DateRangeField dateRangeField, BooleanClause.Occur occurance) { var startDateTime = dateRangeField.StartDate; if (dateRangeField.InclusiveStart) { startDateTime = startDateTime.AddDays(1); } var startDate = startDateTime.ToString(IndexConstants.DateTimeFormat); var endDateTime = dateRangeField.EndDate; if (dateRangeField.InclusiveStart) { endDateTime = endDateTime.AddDays(1); } var endDate = endDateTime.ToString(IndexConstants.DateTimeFormat); var rangeQuery = new RangeQuery(new Term(dateRangeField.FieldName, startDate), new Term(dateRangeField.FieldName, endDate), true); query.Add(rangeQuery, occurance); }
protected void ApplyDateRangeSearchParam(BooleanQuery query, DateRangeSearchParam param, BooleanClause.Occur innerOccurance) { if (param.Ranges.Count <= 0) return; foreach (var dateParam in param.Ranges) { AddDateRangeQuery(query, dateParam, innerOccurance); } }
public virtual List<SkinnyItem> GetItemsInRange(DateRangeSearchParam param) { var globalQuery = new CombinedQuery(); ApplyLanguageClause(globalQuery, param.Language); ApplyTemplateFilter(globalQuery, param.TemplateIds); ApplyLocationFilter(globalQuery, param.LocationIds); ApplyFullTextClause(globalQuery, param.FullTextQuery); var translator = new QueryTranslator(Index); var booleanQuery = translator.ConvertCombinedQuery(globalQuery); var innerOccurance = translator.GetOccur(param.Occurance); ApplyDateRangeSearchParam(booleanQuery, param, innerOccurance); return RunQuery(booleanQuery, param.ShowAllVersions); }