Provides searching tasks using a Lucene.net search index.
Inheritance: ISearchService
Exemplo n.º 1
0
		public RelController(ApplicationSettings settings, UserServiceBase userManager,
			SettingsService settingsService, IRelService relService, SearchService searchService,
			PageHistoryService historyService, IUserContext context)
			: base(settings, userManager, context, settingsService)
		{
			_settingsService = settingsService;
            _relService = relService;
		}
Exemplo n.º 2
0
		public HomeController(ApplicationSettings settings, UserServiceBase userManager, MarkupConverter markupConverter,
			PageService pageService, SearchService searchService, IUserContext context, SettingsService settingsService)
			: base(settings, userManager, context, settingsService) 
		{
			_markupConverter = markupConverter;
			_searchService = searchService;
			PageService = pageService;
		}
Exemplo n.º 3
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_pageService = _container.PageService;
			_searchService = _container.SearchService;

			_searchController = new SearchController(_searchService);
		}
Exemplo n.º 4
0
        public PagesController(ApplicationSettings settings, UserServiceBase userManager,
			SettingsService settingsService, IPageService pageService, SearchService searchService,
			PageHistoryService historyService, IUserContext context)
            : base(settings, userManager, context, settingsService)
        {
            _settingsService = settingsService;
            _pageService = pageService;
            _searchService = searchService;
            _historyService = historyService;
        }
Exemplo n.º 5
0
		public InstallController(ApplicationSettings settings, UserServiceBase userService,
			PageService pageService, SearchService searchService, IRepository respository,
			SettingsService settingsService, IUserContext context, ConfigReaderWriter configReaderWriter)
			: base(settings, userService, context, settingsService) 
		{
			_pageService = pageService;
			_searchService = searchService;
			_repository = respository;
			_settingsService = settingsService;
			_configReaderWriter = configReaderWriter;
		}
Exemplo n.º 6
0
		public ToolsController(ApplicationSettings settings, UserServiceBase userManager,
			SettingsService settingsService, PageService pageService, SearchService searchService, IUserContext context,
			ListCache listCache, PageViewModelCache pageViewModelCache, IWikiImporter wikiImporter, IPluginFactory pluginFactory, WikiExporter wikiExporter)
			: base(settings, userManager, context, settingsService) 
		{
			_pageService = pageService;
			_searchService = searchService;
			_listCache = listCache;
			_pageViewModelCache = pageViewModelCache;
			_wikiImporter = wikiImporter;			
			_wikiExporter = wikiExporter;
		}
Exemplo n.º 7
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_userContext = _container.UserContext;
			_userService = _container.UserService;
			_repositoryMock = _container.Repository;
			_pageService = _container.PageService;
			_searchService = _container.SearchService;

			_searchController = new SearchController(_searchService, _applicationSettings, _userService, _userContext);
		}
Exemplo n.º 8
0
 public RelService(ApplicationSettings settings, IRepository repository, SearchService searchService,
     PageHistoryService historyService, IUserContext context,
     ListCache listCache, PageViewModelCache pageViewModelCache, SiteCache sitecache, IPluginFactory pluginFactory)
     : base(settings, repository)
 {
     _searchService = searchService;
     _markupConverter = new MarkupConverter(settings, repository, pluginFactory);
     _historyService = historyService;
     _context = context;
     _listCache = listCache;
     _pageViewModelCache = pageViewModelCache;
     _siteCache = sitecache;
     _pluginFactory = pluginFactory;
 }
Exemplo n.º 9
0
		public UserManagementController(ApplicationSettings settings, UserServiceBase userManager,
			SettingsService settingsService, PageService pageService, SearchService searchService, IUserContext context,
			ListCache listCache, PageViewModelCache pageViewModelCache, SiteCache siteCache, IWikiImporter wikiImporter, 
			IRepository repository, IPluginFactory pluginFactory)
			: base(settings, userManager, context, settingsService) 
		{
			_settingsService = settingsService;
			_pageService = pageService;
			_searchService = searchService;
			_listCache = listCache;
			_pageViewModelCache = pageViewModelCache;
			_siteCache = siteCache;
			_wikiImporter = wikiImporter;			
			_repository = repository;
			_pluginFactory = pluginFactory;
		}
Exemplo n.º 10
0
        public void Cyrillic_Content_Should_Be_Stored_And_Retrieved_Correctly()
        {
            // Arrange
            SearchService searchService = new SearchService(_config, _repository, _pluginFactory);
            searchService.CreateIndex();

            PageViewModel page1 = CreatePage(1, "admin", "ОШИБКА: неверная последовательность байт для кодировки", "tag1",
                "БД сервера событий была перенесена из PostgreSQL 8.3 на PostgreSQL 9.1.4. Сервер, развернутый на Windows платформе, не мог с ней работать, т.к. установщик PostgreSQL 9.1.4 создает шаблон базы с использованием кодировки UTF8 и, сответственно, новая БД не могла быть создана с требуемой");

            searchService.Add(page1);

            // Act
            List<SearchResultViewModel> results = searchService.Search("ОШИБКА").ToList();

            // Assert
            Assert.That(results[0].ContentSummary, Contains.Substring("БД сервера событий была перенесена из"));
        }
Exemplo n.º 11
0
		public void Search_With_No_Field_Returns_Results()
		{
			// Arrange
			SearchService searchService = new SearchService(_config, _repository, _pluginFactory);
			searchService.CreateIndex();

			PageViewModel page1 = CreatePage(1, "admin", "title content", "tag1", "title content1");
			PageViewModel page2 = CreatePage(2, "admin", "title content", "tag1", "title content2");

			searchService.Add(page1);
			searchService.Add(page2);

			// Act
			List<SearchResultViewModel> results = searchService.Search("title content").ToList();

			// Assert
			Assert.That(results.Count, Is.EqualTo(2)); // Lucene will ignore the 1 and 2 in the content
		}
Exemplo n.º 12
0
		public PageService(ApplicationSettings settings, ISettingsRepository settingsRepository, IPageRepository pageRepository, SearchService searchService, 
			PageHistoryService historyService, IUserContext context, 
			ListCache listCache, PageViewModelCache pageViewModelCache, SiteCache sitecache, IPluginFactory pluginFactory)
		{
			_searchService = searchService;
			_markupConverter = new MarkupConverter(settings, settingsRepository, pageRepository, pluginFactory);
			_historyService = historyService;
			_context = context;
			_listCache = listCache;
			_pageViewModelCache = pageViewModelCache;
			_siteCache = sitecache;
			_pluginFactory = pluginFactory;
			_markupLinkUpdater = new MarkupLinkUpdater(_markupConverter.Parser);

			ApplicationSettings = settings;
			SettingsRepository = settingsRepository;
			PageRepository = pageRepository;
		}
Exemplo n.º 13
0
        public void Delete_Should_Remove_Page_From_Index()
        {
            // Arrange
            SearchService searchService = new SearchService(_config, _repository, _pluginFactory);
            searchService.CreateIndex();

            PageViewModel page1 = CreatePage(1, "admin", "homepage title", "homepage1, tag1", "title content");
            PageViewModel page2 = CreatePage(2, "admin", "random name2", "tag1", "random name 2");

            searchService.Add(page1);
            searchService.Add(page2);

            // Act
            searchService.Delete(page1);
            List<SearchResultViewModel> results = searchService.Search("homepage title").ToList();

            // Assert
            Assert.That(results.Count, Is.EqualTo(0), "homepage title still appears after deletion");
        }
Exemplo n.º 14
0
        public void CreatedBy_Only_Searchable_Using_Field_Syntax()
        {
            // Arrange
            SearchService searchService = new SearchService(_config, _repository, _pluginFactory);
            searchService.CreateIndex();

            PageViewModel page1 = CreatePage(1, "admin", "random name2", "homepage, tag1", "title content 11");
            PageViewModel page2 = CreatePage(2, "admin", "random name2", "tag1, tag", "title content 2");

            searchService.Add(page1);
            searchService.Add(page2);

            // Act
            List<SearchResultViewModel> results = searchService.Search("admin").ToList();
            List<SearchResultViewModel> createdByResults = searchService.Search("createdby: admin").ToList();

            // Assert
            Assert.That(results.Count, Is.EqualTo(0), "admin title count");
            Assert.That(createdByResults.Count, Is.EqualTo(2), "createdby count");
        }
Exemplo n.º 15
0
		public void Search_By_TagsField_Returns_Multiple_Results()
		{
			// Arrange
			SearchService searchService = new SearchService(_config, _repository, _pluginFactory);
			searchService.CreateIndex();

			PageViewModel page1 = CreatePage(1, "admin", "random name1", "homepage1, tag1", "title content");
			PageViewModel page2 = CreatePage(2, "admin", "random name2", "tag1, tag", "title content");
			PageViewModel page3 = CreatePage(3, "admin", "random name3", "tag3, tag", "title content");
			PageViewModel page4 = CreatePage(4, "admin", "random name4", "tag4, tag", "title content");

			searchService.Add(page1);
			searchService.Add(page2);
			searchService.Add(page3);
			searchService.Add(page4);

			// Act
			List<SearchResultViewModel> results = searchService.Search("tags:\"tag1\"").ToList();

			// Assert
			Assert.That(results.Count, Is.EqualTo(2));
		}
Exemplo n.º 16
0
		public void Search_By_Title()
		{
			// Arrange
			SearchService searchService = new SearchService(_config, _repository, _pluginFactory);
			searchService.CreateIndex();

			PageViewModel page1 = CreatePage(1, "admin", "the title", "tag1", "title content");
			PageViewModel page2 = CreatePage(2, "admin", "random name1", "tag1", "title content");
			PageViewModel page3 = CreatePage(3, "admin", "random name2", "tag1", "title content");
			PageViewModel page4 = CreatePage(4, "admin", "random name3", "tag1", "title content");

			searchService.Add(page1);
			searchService.Add(page2);
			searchService.Add(page3);
			searchService.Add(page4);

			// Act
			List<SearchResultViewModel> results = searchService.Search("title:\"the title\"").ToList();

			// Assert
			Assert.That(results.Count, Is.EqualTo(1));
		}
Exemplo n.º 17
0
		public void Setup()
		{
			_container = new MocksAndStubsContainer();

			_applicationSettings = _container.ApplicationSettings;
			_context = _container.UserContext;
			_repository = _container.Repository;
			_settingsService = _container.SettingsService;
			_userService = _container.UserService;
			_pageCache = _container.PageViewModelCache;
			_listCache = _container.ListCache;
			_siteCache = _container.SiteCache;
			_cache = _container.MemoryCache;

			_pageService = _container.PageService;
			_wikiImporter = new ScrewTurnImporter(_applicationSettings, _repository);
			_pluginFactory = _container.PluginFactory;
			_searchService = _container.SearchService;

			_controller = new UserManagementController(_applicationSettings, _userService, _settingsService, _pageService, 
				_searchService, _context, _listCache, _pageCache, _siteCache, _wikiImporter, _repository, _pluginFactory);
		}
Exemplo n.º 18
0
		/// <summary>
		/// Initializes a new instance of the <see cref="SearchController"/> class.
		/// </summary>
		/// <param name="searchService">The search service.</param>
		public SearchController(SearchService searchService)
		{
			_searchService = searchService;
		}
Exemplo n.º 19
0
		public void Search_By_CreatedOnField_Returns_Results()
		{
			// Arrange
			string todaysDate = DateTime.Today.ToShortDateString(); // (SearchService stores dates, not times)
			SearchService searchService = new SearchService(_config, _repository, _pluginFactory);
			searchService.CreateIndex();

			PageViewModel page1 = CreatePage(1, "admin", "random name2", "homepage, tag1", "title content", DateTime.Today);
			PageViewModel page2 = CreatePage(2, "admin", "random name2", "tag1, tag", "title content", DateTime.Today);
			PageViewModel page3 = CreatePage(3, "admin", "random name3", "tag1, tag", "title content", DateTime.Today.AddDays(1));
			PageViewModel page4 = CreatePage(4, "admin", "random name4", "tag1, tag", "title content", DateTime.Today.AddDays(2));

			searchService.Add(page1);
			searchService.Add(page2);
			searchService.Add(page3);
			searchService.Add(page4);

			// Act
			List<SearchResultViewModel> createdOnResults = searchService.Search("createdon:" +todaysDate).ToList();

			// Assert
			Assert.That(createdOnResults.Count, Is.EqualTo(2), "createdon count");
		}
Exemplo n.º 20
0
		public void UpdateSearchIndex(SearchService searchService)
		{
			UpdatedSearch = true;
		}
Exemplo n.º 21
0
		public void Update_Should_Show_In_Index_Search()
		{
			// Arrange
			SearchService searchService = new SearchService(_config, _repository, _pluginFactory);
			searchService.CreateIndex();

			PageViewModel page1 = CreatePage(1, "admin", "homepage title", "homepage1, tag1", "title content");
			PageViewModel page2 = CreatePage(2, "admin", "random name2", "tag1", "random name 2");

			searchService.Add(page1);
			searchService.Add(page2);

			// Act
			page1.Title = "A new hope";
			searchService.Update(page1);

			Thread thread = new Thread(delegate()
			{
				// Perform the test in a new thread, so that the add + delete commit is picked up
				// which is periodically done by Lucene.
				List<SearchResultViewModel> oldResults = searchService.Search("homepage title").ToList();
				List<SearchResultViewModel> newResults = searchService.Search("A new hope").ToList();

				// Assert
				Assert.That(oldResults.Count, Is.EqualTo(0), "old results");
				Assert.That(newResults.Count, Is.EqualTo(1), "new results");
			});
			thread.Start();
		}
Exemplo n.º 22
0
		/// <summary>
		/// Updates the search index after a successful import.
		/// </summary>
		public void UpdateSearchIndex(SearchService searchService)
		{
			searchService.CreateIndex();
		}
Exemplo n.º 23
0
		public void GetContentSummary_Should_Only_Contain_First_150_Characters_For_Summary()
		{
			// Arrange
			SearchService searchService = new SearchService(_config, _repository, _pluginFactory);
			searchService.CreateIndex();

			PageViewModel page1 = CreatePage(1, "admin", "A page title", "tag1", "Lorizzle ipsizzle dolor sit amizzle, (pre character 150 boundary) rizzle adipiscing tellivizzle. Nullizzle sapizzle velizzle, yo mamma volutpat, suscipizzle bow wow wow, gravida vizzle, (post 150 character boundary) shizznit. Pellentesque da bomb tortizzle. Hizzle erizzle. Its fo rizzle izzle sheezy dapibizzle mofo tempizzle tempizzle. Maurizzle away nibh izzle turpis. Phat izzle hizzle. Pellentesque eleifend rhoncus rizzle. Da bomb things dang platea dictumst. Fo shizzle my nizzle dapibizzle. Shiz tellus owned, pretizzle eu, mattizzle ac, bow wow wow its fo rizzle, nunc. Shiz suscipit. Integizzle own yo' we gonna chung sed go to hizzle.");
			searchService.Add(page1);

			// Act
			List<SearchResultViewModel> results = searchService.Search("rizzle").ToList();

			// Assert
			Assert.That(results[0].ContentSummary, Contains.Substring("(pre character 150 boundary)"));
			Assert.That(results[0].ContentSummary, Is.Not.StringContaining("(post character 150 boundary)"));

		}
Exemplo n.º 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchController"/> class.
 /// </summary>
 /// <param name="searchService">The search service.</param>
 public SearchController(SearchService searchService, ApplicationSettings appSettings, UserServiceBase userService, IUserContext userContext)
     : base(appSettings, userService, userContext)
 {
     _searchService = searchService;
 }
Exemplo n.º 25
0
        public InstallControllerStub(ApplicationSettings settings, UserServiceBase userService,
			PageService pageService, SearchService searchService, IRepository respository,
			SettingsService settingsService, IUserContext context, ConfigReaderWriter configReaderWriter)
            : base(settings, userService, pageService, searchService, respository, settingsService, context, configReaderWriter)
        {
        }
Exemplo n.º 26
0
		public void GetContentSummary_Should_Remove_Html_From_Summary()
		{
			// Arrange
			SearchService searchService = new SearchService(_config, _repository, _pluginFactory);
			searchService.CreateIndex();

			PageViewModel page1 = CreatePage(1, "admin", "A page title", "tag1", "**some bold** \n\n=my header=");
			searchService.Add(page1);

			// Act
			List<SearchResultViewModel> results = searchService.Search("my header").ToList();

			// Assert
			Assert.That(results[0].ContentSummary, Is.Not.StringContaining("<b>some bold</b>"));
			Assert.That(results[0].ContentSummary, Is.Not.StringContaining("<h1>my header</h1>"));

		}
Exemplo n.º 27
0
        public PageService(ApplicationSettings settings, ISettingsRepository settingsRepository, IPageRepository pageRepository, SearchService searchService,
                           PageHistoryService historyService, IUserContext context,
                           ListCache listCache, PageViewModelCache pageViewModelCache, SiteCache sitecache, IPluginFactory pluginFactory)
        {
            _searchService      = searchService;
            _markupConverter    = new MarkupConverter(settings, settingsRepository, pageRepository, pluginFactory);
            _historyService     = historyService;
            _context            = context;
            _listCache          = listCache;
            _pageViewModelCache = pageViewModelCache;
            _siteCache          = sitecache;
            _pluginFactory      = pluginFactory;
            _markupLinkUpdater  = new MarkupLinkUpdater(_markupConverter.Parser);

            ApplicationSettings = settings;
            SettingsRepository  = settingsRepository;
            PageRepository      = pageRepository;
        }