public override Dictionary <Type, Func <SystemEntity, IEnumerable <LuceneAction> > > GetRelatedEntities() { return(new Dictionary <Type, Func <SystemEntity, IEnumerable <LuceneAction> > > { { typeof(UrlHistory), entity => { if (entity is UrlHistory) { return new List <LuceneAction> { new LuceneAction { Entity = (entity as UrlHistory).Webpage, Operation = LuceneOperation.Update, IndexDefinition = IndexingHelper.Get <AdminWebpageIndexDefinition>() } }; } return new List <LuceneAction>(); } } }); }
public Query GetQuery() { if (string.IsNullOrWhiteSpace(Term) && string.IsNullOrWhiteSpace(Type) && !CreatedOnTo.HasValue && !CreatedOnFrom.HasValue && Parent == null) { return(new MatchAllDocsQuery()); } BooleanQuery booleanQuery = new BooleanQuery(); if (!string.IsNullOrWhiteSpace(Term)) { IndexDefinition indexDefinition = IndexingHelper.Get <AdminWebpageIndexDefinition>(); Lucene.Net.Analysis.Analyzer analyser = indexDefinition.GetAnalyser(); MultiFieldQueryParser parser = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_30, indexDefinition.SearchableFieldNames, analyser); Query query = Term.SafeGetSearchQuery(parser, analyser); booleanQuery.Add(query, Occur.MUST); } if (CreatedOnFrom.HasValue || CreatedOnTo.HasValue) { booleanQuery.Add(GetDateQuery(), Occur.MUST); } if (!string.IsNullOrEmpty(Type)) { booleanQuery.Add(new TermQuery(new Term(FieldDefinition.GetFieldName <TypeFieldDefinition>(), Type)), Occur.MUST); } if (Parent != null) { booleanQuery.Add( new TermQuery(new Term(FieldDefinition.GetFieldName <ParentIdFieldDefinition>(), Parent.Id.ToString())), Occur.MUST); } return(booleanQuery); }
public override Dictionary <Type, Func <SystemEntity, IEnumerable <LuceneAction> > > GetRelatedEntities() { return(new Dictionary <Type, Func <SystemEntity, IEnumerable <LuceneAction> > > { { typeof(Category), entity => { if (entity is Category) { var category = (entity as Category); Category categoryAlias = null; IList <Product> products = _session.QueryOver <Product>() .JoinAlias(product => product.Categories, () => categoryAlias) .Where(product => categoryAlias.Id == category.Id) .Cacheable() .List(); return products.Select(product => new LuceneAction { Entity = product.Unproxy(), Operation = LuceneOperation.Update, IndexDefinition = IndexingHelper.Get <ProductSearchIndex>() }).ToList(); } return new List <LuceneAction>(); } } }); }
public override Dictionary <Type, Func <SystemEntity, IEnumerable <LuceneAction> > > GetRelatedEntities() { return(new Dictionary <Type, Func <SystemEntity, IEnumerable <LuceneAction> > > { { typeof(Brand), entity => { if (entity is Brand) { var page = (entity as Brand); var products = _session.QueryOver <Product>() .Where(product => product.BrandPage.Id == page.Id) .Cacheable() .List(); return products.Select(product => new LuceneAction { Entity = product.Unproxy(), Operation = LuceneOperation.Update, IndexDefinition = IndexingHelper.Get <ProductSearchIndex>() }).ToList(); } return new List <LuceneAction>(); } } }); }
private static LuceneAction GetAction(Product product) { return(new LuceneAction { Entity = product.Unproxy(), Operation = LuceneOperation.Update, IndexDefinition = IndexingHelper.Get <ProductSearchIndex>() }); }
private static IEnumerable <LuceneAction> GetActions(SystemEntity entity) { var line = entity as ProductOptionValue; if (line != null && line.ProductVariant != null && line.ProductVariant.Product != null) { yield return new LuceneAction { Entity = line.ProductVariant.Product.Unproxy(), Operation = LuceneOperation.Update, IndexDefinition = IndexingHelper.Get <ProductSearchIndex>() } } ; }
private IEnumerable <LuceneAction> GetValueActions(SystemEntity entity) { var line = entity as ProductSpecificationValue; if (line == null) { yield break; } yield return(new LuceneAction { Entity = line.Product.Unproxy(), Operation = LuceneOperation.Update, IndexDefinition = IndexingHelper.Get <ProductSearchIndex>() }); }
public Query Get(ProductSearchQuery searchQuery) { var booleanQuery = new BooleanQuery { ProductSearchPublishedDefinition.PublishedOnly }; if (!searchQuery.Options.Any() && !searchQuery.Specifications.Any() && Math.Abs(searchQuery.PriceFrom - 0) < 0.01 && !searchQuery.PriceTo.HasValue && !searchQuery.CategoryId.HasValue && string.IsNullOrWhiteSpace(searchQuery.SearchTerm) && !searchQuery.BrandId.HasValue) { return(booleanQuery); } if (searchQuery.Options.Any()) { booleanQuery.Add(GetOptionsQuery(searchQuery.Options), Occur.MUST); } if (searchQuery.Specifications.Any()) { booleanQuery.Add(GetSpecificationsQuery(searchQuery.Specifications), Occur.MUST); } if (searchQuery.CategoryId.HasValue) { booleanQuery.Add(GetCategoriesQuery(searchQuery.CategoryId.Value), Occur.MUST); } if (searchQuery.PriceFrom > 0 || searchQuery.PriceTo.HasValue) { booleanQuery.Add(GetPriceRangeQuery(searchQuery), Occur.MUST); } if (!String.IsNullOrWhiteSpace(searchQuery.SearchTerm)) { IndexDefinition indexDefinition = IndexingHelper.Get <ProductSearchIndex>(); Analyzer analyser = indexDefinition.GetAnalyser(); var parser = new MultiFieldQueryParser(Version.LUCENE_30, indexDefinition.SearchableFieldNames, analyser); Query query = searchQuery.SearchTerm.SafeGetSearchQuery(parser, analyser); booleanQuery.Add(query, Occur.MUST); } if (searchQuery.BrandId.HasValue) { booleanQuery.Add(GetBrandQuery(searchQuery.BrandId.Value), Occur.MUST); } return(booleanQuery); }
private static IEnumerable <LuceneAction> GetActions(SystemEntity entity) { var line = entity as ProductSpecificationAttributeOption; if (line == null) { yield break; } var productSpecificationValues = line.Values; foreach (var product in productSpecificationValues.Select(value => value.Product).Where(p => p != null)) { yield return(new LuceneAction { Entity = product.Unproxy(), Operation = LuceneOperation.Update, IndexDefinition = IndexingHelper.Get <ProductSearchIndex>() }); } }
public Query GetQuery() { var booleanQuery = new BooleanQuery { { new TermRangeQuery( FieldDefinition.GetFieldName <PublishedOnFieldDefinition>(), null, DateTools.DateToString(CurrentRequestData.Now, DateTools.Resolution.SECOND), false, true), Occur.MUST } }; if (!String.IsNullOrWhiteSpace(Term)) { var indexDefinition = IndexingHelper.Get <WebpageSearchIndexDefinition>(); var analyser = indexDefinition.GetAnalyser(); var parser = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_30, indexDefinition.SearchableFieldNames, analyser); Query query = Term.SafeGetSearchQuery(parser, analyser); booleanQuery.Add(query, Occur.MUST); } if (CreatedOnFrom.HasValue || CreatedOnTo.HasValue) { booleanQuery.Add(GetDateQuery(), Occur.MUST); } if (!string.IsNullOrEmpty(Type)) { booleanQuery.Add(new TermQuery(new Term(FieldDefinition.GetFieldName <TypeFieldDefinition>(), Type)), Occur.MUST); } if (Parent != null) { booleanQuery.Add( new TermQuery(new Term(FieldDefinition.GetFieldName <ParentIdFieldDefinition>(), Parent.Id.ToString())), Occur.MUST); } return(booleanQuery); }