private ExamineIndexerModel CreateModel(BaseIndexProvider indexer) { var indexerModel = new ExamineIndexerModel() { IndexCriteria = indexer.IndexerData, Name = indexer.Name }; var props = TypeHelper.CachedDiscoverableProperties(indexer.GetType(), mustWrite: false) //ignore these properties .Where(x => !new[] { "IndexerData", "Description", "WorkingFolder" }.InvariantContains(x.Name)) .OrderBy(x => x.Name); foreach (var p in props) { indexerModel.ProviderProperties.Add(p.Name, p.GetValue(indexer, null).ToString()); } var luceneIndexer = indexer as LuceneIndexer; if (luceneIndexer != null && luceneIndexer.IndexExists()) { indexerModel.IsLuceneIndex = true; indexerModel.DocumentCount = luceneIndexer.GetIndexDocumentCount(); indexerModel.FieldCount = luceneIndexer.GetIndexDocumentCount(); indexerModel.IsOptimized = luceneIndexer.IsIndexOptimized(); indexerModel.DeletionCount = luceneIndexer.GetDeletedDocumentsCount(); } return(indexerModel); }
private int NumberOfDeletions(BaseIndexProvider provider) { var numberOfDeletions = 0; var luceneIndexer = provider as LuceneIndexer; if (luceneIndexer != null) { if (luceneIndexer.IndexExists()) { try { using (var reader = luceneIndexer.GetIndexWriter().GetReader()) { numberOfDeletions = reader.NumDeletedDocs(); } } catch { LogHelper.Warn <CamelontaRebuildIndexController>("Camelonta - RebuildIndex. Could not detect deletions."); } } } return(numberOfDeletions); }
/// <summary> /// Initializes a new instance of the <see cref="CachedProductQuery"/> class. /// </summary> /// <param name="service"> /// The service. /// </param> /// <param name="indexProvider"> /// The index provider. /// </param> /// <param name="searchProvider"> /// The search provider. /// </param> /// <param name="enableDataModifiers"> /// The enable data modifiers. /// </param> /// <param name="conversionType"> /// The is for back office editors. /// </param> internal CachedProductQuery(IPageCachedService <IProduct> service, BaseIndexProvider indexProvider, BaseSearchProvider searchProvider, bool enableDataModifiers, DetachedValuesConversionType conversionType) : base(service, indexProvider, searchProvider, enableDataModifiers) { _productService = (ProductService)service; this._conversionType = conversionType; this.Initialize(); }
/// <summary> /// Initializes a new instance of the <see cref="CachedOrderQuery"/> class. /// </summary> /// <param name="service"> /// The service. /// </param> /// <param name="indexProvider"> /// The index provider. /// </param> /// <param name="searchProvider"> /// The search provider. /// </param> internal CachedOrderQuery( IPageCachedService <IOrder> service, BaseIndexProvider indexProvider, BaseSearchProvider searchProvider) : base(service, indexProvider, searchProvider) { _orderService = (OrderService)service; }
/// <summary> /// Initializes a new instance of the <see cref="CachedOrderQuery"/> class. /// </summary> /// <param name="merchelloContext"> /// The <see cref="IMerchelloContext"/>. /// </param> /// <param name="indexProvider"> /// The index provider. /// </param> /// <param name="searchProvider"> /// The search provider. /// </param> /// <param name="enableDataModifiers"> /// A value indicating whether or not data modifiers are enabled. /// </param> internal CachedOrderQuery( IMerchelloContext merchelloContext, BaseIndexProvider indexProvider, BaseSearchProvider searchProvider, bool enableDataModifiers) : base(merchelloContext.Cache, merchelloContext.Services.OrderService, indexProvider, searchProvider, enableDataModifiers) { _orderService = (OrderService)merchelloContext.Services.OrderService; }
/// <summary> /// Initializes a new instance of the <see cref="CachedOrderQuery"/> class. /// </summary> /// <param name="service"> /// The service. /// </param> /// <param name="indexProvider"> /// The index provider. /// </param> /// <param name="searchProvider"> /// The search provider. /// </param> /// <param name="enableDataModifiers"> /// A value indicating whether or not data modifiers are enabled. /// </param> internal CachedOrderQuery( IPageCachedService <IOrder> service, BaseIndexProvider indexProvider, BaseSearchProvider searchProvider, bool enableDataModifiers) : base(service, indexProvider, searchProvider, enableDataModifiers) { _orderService = (OrderService)service; }
/// <summary> /// Initializes a new instance of the <see cref="CachedProductQuery"/> class. /// </summary> /// <param name="merchelloContext"> /// The <see cref="IMerchelloContext"/>. /// </param> /// <param name="indexProvider"> /// The index provider. /// </param> /// <param name="searchProvider"> /// The search provider. /// </param> /// <param name="enableDataModifiers"> /// The enable data modifiers. /// </param> /// <param name="conversionType"> /// The is for back office editors. /// </param> internal CachedProductQuery(IMerchelloContext merchelloContext, BaseIndexProvider indexProvider, BaseSearchProvider searchProvider, bool enableDataModifiers, DetachedValuesConversionType conversionType) : base(merchelloContext.Cache, merchelloContext.Services.ProductService, indexProvider, searchProvider, enableDataModifiers) { _productService = (ProductService)merchelloContext.Services.ProductService; this._conversionType = conversionType; _productContentFactory = new Lazy <ProductContentFactory>(() => new ProductContentFactory()); _cache = new VirtualProductContentCache(merchelloContext.Cache, this.GetProductContent, enableDataModifiers); this.Initialize(); }
/// <summary> /// Initializes a new instance of the <see cref="CachedInvoiceQuery"/> class. /// </summary> /// <param name="service"> /// The service. /// </param> /// <param name="getOrders"> /// The get Orders. /// </param> /// <param name="indexProvider"> /// The index provider. /// </param> /// <param name="searchProvider"> /// The search provider. /// </param> internal CachedInvoiceQuery( IPageCachedService <IInvoice> service, Func <Guid, IEnumerable <OrderDisplay> > getOrders, BaseIndexProvider indexProvider, BaseSearchProvider searchProvider) : base(service, indexProvider, searchProvider) { _invoiceService = (InvoiceService)service; _getOrders = getOrders; }
/// <summary> /// Initializes a new instance of the <see cref="CachedInvoiceQuery"/> class. /// </summary> /// <param name="merchelloContext"> /// The <see cref="IMerchelloContext"/>. /// </param> /// <param name="getOrders"> /// The get Orders. /// </param> /// <param name="indexProvider"> /// The index provider. /// </param> /// <param name="searchProvider"> /// The search provider. /// </param> /// <param name="enableDataModifiers"> /// A value indicating whether or not data modifiers are enabled. /// </param> internal CachedInvoiceQuery( IMerchelloContext merchelloContext, Func <Guid, IEnumerable <OrderDisplay> > getOrders, BaseIndexProvider indexProvider, BaseSearchProvider searchProvider, bool enableDataModifiers) : base(merchelloContext.Cache, merchelloContext.Services.InvoiceService, indexProvider, searchProvider, enableDataModifiers) { _invoiceService = (InvoiceService)merchelloContext.Services.InvoiceService; _getOrders = getOrders; }
/// <summary> /// Helper function for ReindexAllFullTextNodes /// </summary> /// <param name="Indexer"></param> /// <param name="Content"></param> protected static void RecursiveIndexNodes(BaseIndexProvider Indexer, IContent Content) { if (Content != null && Content.Published && !Content.Trashed) { ReIndexNode(Indexer, (Content)Content); if (ApplicationContext.Current.Services.ContentService.HasChildren(Content.Id)) { foreach (var child in ApplicationContext.Current.Services.ContentService.GetChildren(Content.Id)) { RecursiveIndexNodes(Indexer, child); } } } }
/// <summary> /// Initializes a new instance of the <see cref="CachedQueryBase{TEntity,TDisplay}"/> class. /// </summary> /// <param name="service"> /// The service. /// </param> /// <param name="indexProvider"> /// The Examine Index provider. /// </param> /// <param name="searchProvider"> /// The Examine Search provider. /// </param> protected CachedQueryBase( IPageCachedService <TEntity> service, BaseIndexProvider indexProvider, BaseSearchProvider searchProvider) { Mandate.ParameterNotNull(service, "service"); Mandate.ParameterNotNull(indexProvider, "indexProvider"); Mandate.ParameterNotNull(searchProvider, "searchProvider"); _service = service; _indexProvider = indexProvider; _searchProvider = searchProvider; _resultFactory = new Lazy <QueryResultFactory <TDisplay> >(() => new QueryResultFactory <TDisplay>(PerformMapSearchResultToDisplayObject, GetDisplayObject)); }
/// <summary> /// Boot-up is completed, this allows you to perform any other boot-up logic required for the application. /// Resolution is frozen so now they can be used to resolve instances. /// </summary> /// <param name="umbracoApplication"> /// The current <see cref="UmbracoApplicationBase"/> /// </param> /// <param name="applicationContext"> /// The Umbraco <see cref="ApplicationContext"/> for the current application. /// </param> protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { // Assign the fallback helper. This is hacky but there is simply no way to ensure that we have a context // When working with background threads. UmbracoHelper helper = new UmbracoHelper(UmbracoContext.Current); ContentHelper.FallbackUmbracoHelper = helper; // Assign indexer for full text searching. BaseIndexProvider baseIndexProvider = ExamineManager.Instance.IndexProviderCollection[SearchConstants.IndexerName]; if (baseIndexProvider != null) { baseIndexProvider.GatheringNodeData += (sender, e) => this.GatheringNodeData(sender, e, helper); } }
private ExamineIndexerModel CreateModel(BaseIndexProvider indexer) { var indexerModel = new ExamineIndexerModel() { IndexCriteria = indexer.IndexerData, Name = indexer.Name }; var props = TypeHelper.CachedDiscoverableProperties(indexer.GetType(), mustWrite: false) //ignore these properties .Where(x => new[] { "IndexerData", "Description", "WorkingFolder" }.InvariantContains(x.Name) == false) .OrderBy(x => x.Name); foreach (var p in props) { var val = p.GetValue(indexer, null); if (val == null) { LogHelper.Warn <ExamineManagementApiController>("Property value was null when setting up property on indexer: " + indexer.Name + " property: " + p.Name); val = string.Empty; } indexerModel.ProviderProperties.Add(p.Name, val.ToString()); } var luceneIndexer = indexer as LuceneIndexer; if (luceneIndexer != null) { indexerModel.IsLuceneIndex = true; if (luceneIndexer.IndexExists()) { indexerModel.DocumentCount = luceneIndexer.GetIndexDocumentCount(); indexerModel.FieldCount = luceneIndexer.GetIndexFieldCount(); indexerModel.IsOptimized = luceneIndexer.IsIndexOptimized(); indexerModel.DeletionCount = luceneIndexer.GetDeletedDocumentsCount(); } else { indexerModel.DocumentCount = 0; indexerModel.FieldCount = 0; indexerModel.IsOptimized = true; indexerModel.DeletionCount = 0; } } return(indexerModel); }
/// <summary> /// Generally used for unit testing to use an explicit examine searcher /// </summary> /// <param name="applicationContext"></param> /// <param name="searchProvider"></param> /// <param name="indexProvider"></param> internal PublishedMediaCache(ApplicationContext applicationContext, BaseSearchProvider searchProvider, BaseIndexProvider indexProvider) { if (applicationContext == null) { throw new ArgumentNullException("applicationContext"); } if (searchProvider == null) { throw new ArgumentNullException("searchProvider"); } if (indexProvider == null) { throw new ArgumentNullException("indexProvider"); } _applicationContext = applicationContext; _searchProvider = searchProvider; _indexProvider = indexProvider; }
/// <summary> /// Initializes a new instance of the <see cref="CachedQueryBase{TEntity,TDisplay}"/> class. /// </summary> /// <param name="cacheHelper"> /// The <see cref="CacheHelper"/>. /// </param> /// <param name="service"> /// The service. /// </param> /// <param name="indexProvider"> /// The Examine Index provider. /// </param> /// <param name="searchProvider"> /// The Examine Search provider. /// </param> /// <param name="enableDataModifiers"> /// A value indicating whether or not data modifiers are enabled. /// </param> protected CachedQueryBase( CacheHelper cacheHelper, IPageCachedService <TEntity> service, BaseIndexProvider indexProvider, BaseSearchProvider searchProvider, bool enableDataModifiers) { Mandate.ParameterNotNull(service, "service"); Mandate.ParameterNotNull(indexProvider, "indexProvider"); Mandate.ParameterNotNull(searchProvider, "searchProvider"); Mandate.ParameterNotNull(cacheHelper, "cacheHelper"); _service = service; _indexProvider = indexProvider; _searchProvider = searchProvider; _enableDataModifiers = enableDataModifiers; this.PagedKeyCache = new PagedKeyQueryCache(cacheHelper); _resultFactory = new Lazy <QueryResultFactory <TDisplay> >(() => new QueryResultFactory <TDisplay>(PerformMapSearchResultToDisplayObject, GetDisplayObject)); }
/// <summary> /// reindex this single document in the supplied index /// </summary> /// <param name="Indexer"></param> /// <param name="Content"></param> protected static void ReIndexNode(BaseIndexProvider Indexer, IContent Content) { if (Content != null) { var xElement = Content.ToXml(); if (xElement != null) { try { Indexer.ReIndexNode(xElement, IndexTypes.Content); } catch (Exception ex) { if (Library.IsCritical(ex)) { throw; } } } } }
public BaseExamineSearcher(string name) { Searcher = ExamineManager.Instance.SearchProviderCollection[name + "Searcher"]; Indexer = ExamineManager.Instance.IndexProviderCollection[name + "Indexer"]; }
private SkriftGridExamineIndexer() { BaseIndexProvider externalIndexer = ExamineManager.Instance.IndexProviderCollection["ExternalIndexer"]; externalIndexer.GatheringNodeData += OnExamineGatheringNodeData; }
private ExamineIndexerModel CreateModel(BaseIndexProvider indexer) { var indexerModel = new ExamineIndexerModel() { IndexCriteria = indexer.IndexerData, Name = indexer.Name }; var props = TypeHelper.CachedDiscoverableProperties(indexer.GetType(), mustWrite: false) //ignore these properties .Where(x => new[] { "IndexerData", "Description", "WorkingFolder" }.InvariantContains(x.Name) == false) .OrderBy(x => x.Name); foreach (var p in props) { var val = p.GetValue(indexer, null); if (val == null) { // Do not warn for new new attribute that is optional if (string.Equals(p.Name, "DirectoryFactory", StringComparison.InvariantCultureIgnoreCase) == false) { LogHelper.Warn <ExamineManagementApiController>("Property value was null when setting up property on indexer: " + indexer.Name + " property: " + p.Name); } val = string.Empty; } indexerModel.ProviderProperties.Add(p.Name, val.ToString()); } var luceneIndexer = indexer as LuceneIndexer; if (luceneIndexer != null) { indexerModel.IsLuceneIndex = true; if (luceneIndexer.IndexExists()) { Exception indexError; indexerModel.IsHealthy = luceneIndexer.IsHealthy(out indexError); if (indexerModel.IsHealthy == false) { //we cannot continue at this point indexerModel.Error = indexError.ToString(); return(indexerModel); } indexerModel.DocumentCount = luceneIndexer.GetIndexDocumentCount(); indexerModel.FieldCount = luceneIndexer.GetIndexFieldCount(); indexerModel.IsOptimized = luceneIndexer.IsIndexOptimized(); indexerModel.DeletionCount = luceneIndexer.GetDeletedDocumentsCount(); } else { indexerModel.DocumentCount = 0; indexerModel.FieldCount = 0; indexerModel.IsOptimized = true; indexerModel.DeletionCount = 0; } } return(indexerModel); }
/// <summary> /// Initializes a new instance of the <see cref="CachedCustomerQuery"/> class. /// </summary> /// <param name="service"> /// The service. /// </param> /// <param name="indexProvider"> /// The index provider. /// </param> /// <param name="searchProvider"> /// The search provider. /// </param> /// <param name="getInvoicesByCustomer"> /// The get Invoices By Customer. /// </param> internal CachedCustomerQuery(IPageCachedService <ICustomer> service, BaseIndexProvider indexProvider, BaseSearchProvider searchProvider, Func <Guid, IEnumerable <InvoiceDisplay> > getInvoicesByCustomer) : base(service, indexProvider, searchProvider) { _customerService = (CustomerService)service; _getInvoiceByCustomer = getInvoicesByCustomer; }
/// <summary> /// Initializes a new instance of the <see cref="CachedCustomerQuery"/> class. /// </summary> /// <param name="service"> /// The service. /// </param> /// <param name="indexProvider"> /// The index provider. /// </param> /// <param name="searchProvider"> /// The search provider. /// </param> internal CachedCustomerQuery(IPageCachedService <ICustomer> service, BaseIndexProvider indexProvider, BaseSearchProvider searchProvider) : this(service, indexProvider, searchProvider, new CachedInvoiceQuery(MerchelloContext.Current.Services.InvoiceService).GetByCustomerKey) { }
/// <summary> /// Initializes a new instance of the <see cref="CachedCustomerQuery"/> class. /// </summary> /// <param name="service"> /// The service. /// </param> /// <param name="indexProvider"> /// The index provider. /// </param> /// <param name="searchProvider"> /// The search provider. /// </param> internal CachedCustomerQuery(IPageCachedService <ICustomer> service, BaseIndexProvider indexProvider, BaseSearchProvider searchProvider) : base(service, indexProvider, searchProvider) { _customerService = (CustomerService)service; }
public ExamineEvents() { BaseIndexProvider indexer = ExamineManager.Instance.IndexProviderCollection["FrontEndWebsiteIndexer"]; indexer.GatheringNodeData += indexer_GatheringNodeData; }
/// <summary> /// Initializes a new instance of the <see cref="CachedProductQuery"/> class. /// </summary> /// <param name="service"> /// The service. /// </param> /// <param name="indexProvider"> /// The index provider. /// </param> /// <param name="searchProvider"> /// The search provider. /// </param> /// <param name="enableDataModifiers"> /// A value indicating whether or not data modifiers are enabled. /// </param> public CachedProductQuery(IPageCachedService <IProduct> service, BaseIndexProvider indexProvider, BaseSearchProvider searchProvider, bool enableDataModifiers) : base(service, indexProvider, searchProvider, enableDataModifiers) { _productService = (ProductService)service; this.Initialize(); }
/// <summary> /// Initializes a new instance of the <see cref="CachedProductQuery"/> class. /// </summary> /// <param name="service"> /// The service. /// </param> /// <param name="indexProvider"> /// The index provider. /// </param> /// <param name="searchProvider"> /// The search provider. /// </param> public CachedProductQuery(IPageCachedService <IProduct> service, BaseIndexProvider indexProvider, BaseSearchProvider searchProvider) : base(service, indexProvider, searchProvider) { _productService = (ProductService)service; }
/// <summary> /// Generally used for unit testing to use an explicit examine searcher /// </summary> /// <param name="searchProvider"></param> /// <param name="indexProvider"></param> internal PublishedMediaCache(BaseSearchProvider searchProvider, BaseIndexProvider indexProvider) { _searchProvider = searchProvider; _indexProvider = indexProvider; }
/// <summary> /// Generally used for unit testing to use an explicit examine searcher /// </summary> /// <param name="searchProvider"></param> /// <param name="indexProvider"></param> internal DefaultPublishedMediaStore(BaseSearchProvider searchProvider, BaseIndexProvider indexProvider) { _searchProvider = searchProvider; _indexProvider = indexProvider; }
/// <summary> /// Internal constructor used for unit tests /// </summary> /// <param name="result"></param> /// <param name="indexer"></param> /// <param name="searcher"></param> internal ExamineBackedMedia(SearchResult result, BaseIndexProvider indexer, BaseSearchProvider searcher) : this(result) { _indexer = indexer; _searcher = searcher; }
/// <summary> /// Initializes a new instance of the <see cref="CachedCustomerQuery"/> class. /// </summary> /// <param name="merchelloContext"> /// The <see cref="IMerchelloContext"/>. /// </param> /// <param name="indexProvider"> /// The index provider. /// </param> /// <param name="searchProvider"> /// The search provider. /// </param> /// <param name="enableDataModifiers"> /// A value indicating whether or not data modifiers are enabled. /// </param> internal CachedCustomerQuery(IMerchelloContext merchelloContext, BaseIndexProvider indexProvider, BaseSearchProvider searchProvider, bool enableDataModifiers) : this(merchelloContext, indexProvider, searchProvider, new CachedInvoiceQuery(merchelloContext, enableDataModifiers).GetByCustomerKey, enableDataModifiers) { }
/// <summary> /// Initializes a new instance of the <see cref="CachedCustomerQuery"/> class. /// </summary> /// <param name="merchelloContext"> /// The <see cref="IMerchelloContext"/>. /// </param> /// <param name="indexProvider"> /// The index provider. /// </param> /// <param name="searchProvider"> /// The search provider. /// </param> /// <param name="getInvoicesByCustomer"> /// The get Invoices By Customer. /// </param> /// <param name="enableDataModifiers"> /// A value indicating whether or not data modifiers are enabled. /// </param> internal CachedCustomerQuery(IMerchelloContext merchelloContext, BaseIndexProvider indexProvider, BaseSearchProvider searchProvider, Func <Guid, IEnumerable <InvoiceDisplay> > getInvoicesByCustomer, bool enableDataModifiers) : base(merchelloContext.Cache, merchelloContext.Services.CustomerService, indexProvider, searchProvider, enableDataModifiers) { _customerService = (CustomerService)merchelloContext.Services.CustomerService; _getInvoiceByCustomer = getInvoicesByCustomer; }