UpdateIndex() public method

public UpdateIndex ( ) : void
return void
コード例 #1
0
        public LuceneIndexingJob(TimeSpan frequence, Func <EntitiesContext> contextThunk, TimeSpan timeout, LuceneIndexLocation location)
            : base("Lucene", frequence, timeout)
        {
            _updateIndex = () =>
            {
                using (var context = contextThunk())
                {
                    var indexingService = new LuceneIndexingService(
                        new EntityRepository <Package>(context),
                        new EntityRepository <CuratedPackageVersion>(context),
                        LuceneCommon.GetDirectory(location),
                        null);
                    indexingService.UpdateIndex();
                }
            };

            // Updates the index synchronously first time job is created.
            // For startup code resiliency, we should handle exceptions for the database being down.
            try
            {
                _updateIndex();
            }
            catch (SqlException e)
            {
                QuietLog.LogHandledException(e);
            }
            catch (DataException e)
            {
                QuietLog.LogHandledException(e);
            }
        }
コード例 #2
0
        public LuceneIndexingJob(TimeSpan frequence, Func<EntitiesContext> contextThunk, TimeSpan timeout)
            : base("Lucene", frequence, timeout)
        {
            var context = contextThunk();

            _indexingService = new LuceneIndexingService(
                new EntityRepository<Package>(context),
                new EntityRepository<CuratedPackage>(context),
                LuceneCommon.GetDirectory(),
                null);

            // Updates the index synchronously first time job is created.
            // For startup code resiliency, we should handle exceptions for the database being down.
            try
            {
                _indexingService.UpdateIndex();
            }
            catch (SqlException e)
            {
                QuietLog.LogHandledException(e);
            }
            catch (DataException e)
            {
                QuietLog.LogHandledException(e);
            }
        }
コード例 #3
0
        public LuceneIndexingJob(TimeSpan frequence, TimeSpan timeout, LuceneIndexingService indexingService)
            : base("Lucene", frequence, timeout)
        {
            _indexingService = indexingService;

            // Updates the index synchronously first time job is created.
            // For startup code resiliency, we should handle exceptions for the database being down.
            try
            {
                _indexingService.UpdateIndex();
            }
            catch (SqlException e)
            {
                QuietLog.LogHandledException(e);
            }
            catch (DataException e)
            {
                QuietLog.LogHandledException(e);
            }
        }
コード例 #4
0
        public LuceneIndexingJob(TimeSpan frequence, TimeSpan timeout, LuceneIndexingService indexingService)
            : base("Lucene", frequence, timeout)
        {
            _indexingService = indexingService;

            // Updates the index synchronously first time job is created.
            // For startup code resiliency, we should handle exceptions for the database being down.
            try
            {
                _indexingService.UpdateIndex();
            }
            catch (SqlException e)
            {
                QuietLog.LogHandledException(e);
            }
            catch (DataException e)
            {
                QuietLog.LogHandledException(e);
            }
        }
コード例 #5
0
        public LuceneIndexingJob(TimeSpan frequence, TimeSpan timeout, LuceneIndexingService indexingService)
            : base("Lucene", frequence, timeout)
        {
            _indexingService = indexingService;

            try
            {
                _indexingService.UpdateIndex();
            }
            catch (SqlException e)
            {
                // Log but swallow the exception
                ErrorSignal.FromCurrentContext().Raise(e);
            }
            catch (DataException e)
            {
                // Log but swallow the exception
                ErrorSignal.FromCurrentContext().Raise(e);
            }
        }
コード例 #6
0
        public LuceneIndexingJob(TimeSpan frequence, TimeSpan timeout, LuceneIndexingService indexingService)
            : base("Lucene", frequence, timeout)
        {
            _indexingService = indexingService;

            try
            {
                _indexingService.UpdateIndex();
            }
            catch (SqlException e)
            {
                // Log but swallow the exception
                ErrorSignal.FromCurrentContext().Raise(e);
            }
            catch (DataException e)
            {
                // Log but swallow the exception
                ErrorSignal.FromCurrentContext().Raise(e);
            }
        }
コード例 #7
0
        public LuceneIndexingJob(TimeSpan frequence, Func <EntitiesContext> contextThunk, TimeSpan timeout)
            : base("Lucene", frequence, timeout)
        {
            _indexingService = new LuceneIndexingService(
                new PackageSource(contextThunk()),
                LuceneCommon.GetDirectory());

            // Updates the index synchronously first time job is created.
            // For startup code resiliency, we should handle exceptions for the database being down.
            try
            {
                _indexingService.UpdateIndex();
            }
            catch (SqlException e)
            {
                QuietLog.LogHandledException(e);
            }
            catch (DataException e)
            {
                QuietLog.LogHandledException(e);
            }
        }
コード例 #8
0
 public LuceneIndexingJob(TimeSpan frequence, TimeSpan timeout)
     : base("Lucene", frequence, timeout)
 {
     indexingService = new LuceneIndexingService();
     indexingService.UpdateIndex();
 }
コード例 #9
0
 public LuceneIndexingJob(TimeSpan frequence, TimeSpan timeout)
     : base("Lucene", frequence, timeout)
 {
     indexingService = new LuceneIndexingService();
     indexingService.UpdateIndex();
 }
コード例 #10
0
ファイル: Program.cs プロジェクト: henrycomein/NuGetGallery
        static void Main(string[] args)
        {
            var packageDataJson = File.ReadAllText(@"samplePackageData.json");
            var asArray = JArray.Parse(packageDataJson);
            List<Package> packages = LoadPackages(asArray);

            Lucene.Net.Store.Directory d = new Lucene.Net.Store.RAMDirectory();
            var packageSource = new Mock<IPackageSource>();
            packageSource
                .Setup(ps => ps.GetPackagesForIndexing(It.IsAny<DateTime?>()))
                .Returns(new PackageIndexEntity[0].AsQueryable());

            var luceneIndexingService = new LuceneIndexingService(packageSource.Object, d);
            luceneIndexingService.UpdateIndex(forceRefresh: true);
            luceneIndexingService.AddPackages(packages.Select(p => new PackageIndexEntity(p)).ToList(), true);
            luceneSearchService = new LuceneSearchService(d);

            TestSearch("jQuery", "jQuery", 1);
            TestSearch("jqueryui", "jQuery.UI.Combined", 4);

            TestSearch("EntityFramework", "EntityFramework", 1);
            TestSearch("Entity Framework", "EntityFramework", 1);
            TestSearch("entity", "EntityFramework", 1);
            //TestSearch("EF", "EntityFramework", 10); //Currently it's not high in the results AT ALL. Should it be?

            TestSearch("Windows.Azure.Storage", "WindowsAzure.Storage", 1);
            TestSearch("Windows Azure Storage", "WindowsAzure.Storage", 1);
            TestSearch("Azure Storage", "WindowsAzure.Storage", 1);

            TestSearch("Windows.Azure.Caching", "Microsoft.WindowsAzure.Caching", 1);
            TestSearch("Windows Azure Caching", "Microsoft.WindowsAzure.Caching", 1);
            TestSearch("Azure Caching", "Microsoft.WindowsAzure.Caching", 1);
            TestSearch("Azure Cache", "Microsoft.WindowsAzure.Caching", 1);
            TestSearch("Windows Azure Cache", "Microsoft.WindowsAzure.Caching", 1);

            // These 3 popular 'service bus' packages are all in top 5 at time of building this corpus
            // Actually NServiceBus has the most downloads, but is lowest ranked for some reason, well, that might change some day.
            TestSearch("NServiceBus", "NServiceBus", 5);
            TestSearch("Rhino.ServiceBus", "Rhino.ServiceBus", 5);
            TestSearch("ServiceBus", "WindowsAzure.ServiceBus", 5);

            // By FAR the most popular json package
            TestSearch("json", "NewtonSoft.Json", 1);
            TestSearch("Json.net", "NewtonSoft.Json", 1);
            TestSearch("Newtonsoft", "NewtonSoft.Json", 1);

            // A popular json javascript package
            TestSearch("json javascript", "json2", 1);
            TestSearch("json js", "json2", 1);

            // Some other results with justifiably good relevance for json include the 'json' package, and ServiceStack.Text 
            TestSearch("json", "json", 10);
            TestSearch("json", "ServiceStack.Text", 10);

            TestSearch("Microsoft web api", "Microsoft.AspNet.WebApi", 3);

            TestSearch("microsoft http", "Microsoft.AspNet.WebApi", 4);
            TestSearch("microsoft http", "Microsoft.AspNet.WebApi.WebHost", 4);
            TestSearch("microsoft http", "Microsoft.Net.Http", 4);
            TestSearch("microsoft http", "Microsoft.Web.Infrastructure", 4);

            // Finding some misc packages by their distinctive ids
            TestSearch("Hammock", "Hammock", 1);
            TestSearch("WebActivator", "WebActivatorEx", 1);
            TestSearch("Modernizr", "Modernizr", 1);
            TestSearch("SimpleInjector", "SimpleInjector", 1);
            TestSearch("Simple Injector", "SimpleInjector", 1);

            // Some more general term looking searches
            TestSearch("Asp.net Mvc", "Microsoft.AspNet.Mvc", 2); //unbelievably it's losing to elmah...
            TestSearch("asp.net web pages", "Microsoft.AspNet.WebPages", 1);
            TestSearch("logging", "Elmah", 1);
            TestSearch("search", "Lucene.Net", 1);
            TestSearch("lucene", "Lucene.Net", 1);
            TestSearch("search", "NHibernate.Search", 20);
            TestSearch("hibernate", "NHibernate", 1);
            TestSearch("hibernate", "FluentNHibernate", 2);
            TestSearch("hibernate profiler", "NHibernateProfiler", 4);
            TestSearch("sql profiler", "MiniProfiler", 1);
            TestSearch("sql profiler", "LinqToSqlProfiler", 5);
            TestSearch("haacked", "RouteMagic", 2);
            TestSearch("haacked", "MVcHaack.Ajax", 4);
            TestSearch("haacked", "WebBackgrounder", 5);
            TestSearch("haacked", "routedebugger", 5);
            
            TestSearch("NuGet", "NuGet.Core", 3);
            TestSearch("NuGet", "NuGet.CommandLine", 2);
            TestSearch("NuGet", "NuGet.Build", 3);

            TestSearch("Mock", "RhinoMocks", 4);
            TestSearch("Mock", "NUnit.Mocks", 4);
            TestSearch("Mock", "Moq", 4);
            TestSearch("Mock", "FakeItEasy", 20);
            TestSearch("Mock", "Ninject.MockingKernel", 30);
            TestSearch("Mock", "AutoWrockTestable", 30);
            TestSearch("Mock", "Nukito", 40);
            TestSearch("Mock", "MockJockey", 50);
            TestSearch("Mock", "Machine.Specifications.AutoMocking", 50);
            TestSearch("Mock", "WP-Fx.EasyMoq", 60);

            TestSearch("razor", "Microsoft.AspNet.Razor", 1);
            TestSearch("razor 2", "Microsoft.AspNet.Razor", 1);
            TestSearch("memes", "FourOne.Memes", 1);
            TestSearch("ninject", "Ninject", 1);
            TestSearch("nunit", "NUnit", 1);
            TestSearch("testing", "NUnit", 1);
            TestSearch("testing", "xunit", 30); //It should probably be higher
            TestSearch("Asp.net MVC scaffolding", "MvcScaffolding", 3);
            TestSearch("Asp.net MVC scaffolding", "NLibScaffolding", 90);
            TestSearch("Asp.net MVC scaffolding", "WijmoMvcScaffolding", 120);
            TestSearch("Asp.net MVC scaffolding", "MvcScaffolding.Obsidian", 130);
            TestSearch("mvc scaffold", "MvcScaffolding", 8);
            TestSearch("mvc scaffold", "ModelScaffolding", 20);
            TestSearch("Microsoft web infrastructure", "Microsoft.Web.Infrastructure", 1);
            TestSearch("Dotnetopenauth", "DotNetOpenAuth", 1);
            TestSearch("OpenID", "DotNetOpenAuth.OpenId.Core", 1);
            TestSearch("image resizer", "ImageResizer", 1);
            TestSearch("parsing", "CommandLineParser", 10);
            TestSearch("knockoutjs", "knockoutjs", 1);
            TestSearch("knockout js", "knockoutjs", 3); //it should probably be higher, i.e. beating json.net
            // TestSearch("knockout.js", "knockoutjs", 1); // fails to find it
            TestSearch("helpers", "microsoft-web-helpers", 1);
            TestSearch("fluent mongo", "FluentMongo", 1);
            TestSearch("fluent mongo", "MongoFluentUpdater", 15);
            TestSearch("mongo", "mongocsharpdriver", 1);
            TestSearch("mongo", "FluentMongo", 2);
            TestSearch("mongo elmah", "elmah.mongodb", 15); //should be higher?

            // These guys are by far the most popular DI packages
            TestSearch("injection", "Unity", 2);
            TestSearch("injection", "Ninject", 2);
            TestSearch("dependency injection", "Unity", 2);
            TestSearch("dependency injection", "Ninject", 2);
        }