public void ClearRepository()
 {
     parsers.Clear();
     wordSplitter = null;
     resultsReorderer = null;
     queryWeightsSupplier = null;
     queryRewriter = null;
     indexFilterManager = null;
 }
        public void FindAndRegisterValidExtensionPoints_RemovesInvalidCustomQueryWeightsSupplierConfiguration()
        {
            CreateExtensionPointsConfiguration(addInvalidQueryWeightsSupplierConfiguration: true);
            ExtensionPointsConfigurationAnalyzer.FindAndRegisterValidExtensionPoints(extensionPointsConfiguration, logger);

            IQueryWeightsSupplier queryWeightsSupplier = ExtensionPointsRepository.Instance.GetQueryWeightsSupplierImplementation();

            Assert.IsNotNull(queryWeightsSupplier, "Default query weights supplier should be used!");
            Assert.AreEqual(queryWeightsSupplier.GetType().FullName, "Sando.Indexer.Searching.QueryWeightsSupplier", "Invalid query weights supplier returned!");

            string logFileContent = File.ReadAllText(logFilePath);

            Assert.IsTrue(logFileContent.Contains("Invalid query weights supplier configuration found - it will be omitted during registration process."), "Log file should contain information about removed invalid word splitter configuration!");
        }
        public void FindAndRegisterValidExtensionPoints_RegistersUsableCustomQueryWeightsSupplier()
        {
            CreateExtensionPointsConfiguration(addValidQueryWeightsSupplierConfiguration: true);
            ExtensionPointsConfigurationAnalyzer.FindAndRegisterValidExtensionPoints(extensionPointsConfiguration, logger);

            IQueryWeightsSupplier queryWeightsSupplier = ExtensionPointsRepository.Instance.GetQueryWeightsSupplierImplementation();

            Assert.IsNotNull(queryWeightsSupplier, "Query weights supplier should be registered!");
            Assert.AreEqual(queryWeightsSupplier.GetType().FullName, "Sando.TestExtensionPoints.TestQueryWeightsSupplier", "Invalid query weights supplier returned!");

            Dictionary <string, float> weights = null;

            Assert.DoesNotThrow(() => weights = queryWeightsSupplier.GetQueryWeightsValues());
            Assert.IsTrue(weights != null && weights.Count() == 2, "Invalid results from SetQueryWeightsValues method!");
            Assert.AreEqual(weights["field1"], 2, "First weight is invalid!");
            Assert.AreEqual(weights["field2"], 3, "Second weight is invalid!");
        }
Beispiel #4
0
        private static void FindAndRegisterValidQueryWeightsSupplierExtensionPoints(ExtensionPointsConfiguration extensionPointsConfiguration, ILog logger)
        {
            logger.Info("Reading query weights supplier extension point configuration started");
            BaseExtensionPointConfiguration queryWeightsSupplierConfiguration = extensionPointsConfiguration.QueryWeightsSupplierConfiguration;

            if (queryWeightsSupplierConfiguration != null)
            {
                try
                {
                    logger.Info(String.Format("Query weights supplier found: {0}, from assembly: {1}", queryWeightsSupplierConfiguration.FullClassName, queryWeightsSupplierConfiguration.LibraryFileRelativePath));
                    IQueryWeightsSupplier queryWeightsSupplier = CreateInstance <IQueryWeightsSupplier>(extensionPointsConfiguration.PluginDirectoryPath, queryWeightsSupplierConfiguration.LibraryFileRelativePath, queryWeightsSupplierConfiguration.FullClassName);
                    ExtensionPointsRepository.Instance.RegisterQueryWeightsSupplierImplementation(queryWeightsSupplier);
                    logger.Info(String.Format("Query weights supplier {0} successfully registered.", queryWeightsSupplierConfiguration.FullClassName));
                }
                catch (Exception ex)
                {
                    logger.Error(String.Format("Query weights supplier {0} cannot be registered: {1}", queryWeightsSupplierConfiguration.FullClassName, ex.Message));
                }
            }
            logger.Info("Reading query weights supplier extension point configuration finished");
        }
        public void RegisterQueryWeightsSupplierImplementation(IQueryWeightsSupplier queryWeightsSupplier)
        {
            Contract.Requires(queryWeightsSupplier != null, "ExtensionPointsManager:RegisterQueryWeightsSupplierImplementation - queryWeightsSupplier cannot be null!");

            this.queryWeightsSupplier = queryWeightsSupplier;
        }
        public void RegisterQueryWeightsSupplierImplementation(IQueryWeightsSupplier queryWeightsSupplier)
        {
            Contract.Requires(queryWeightsSupplier != null, "ExtensionPointsManager:RegisterQueryWeightsSupplierImplementation - queryWeightsSupplier cannot be null!");

            this.queryWeightsSupplier = queryWeightsSupplier;
        }