public virtual void GlobalSetup()
        {
            const string connectionString = "server=localhost;port=3306;database=lucene;uid=root;password=password;Allow User Variables=True;";

            Options  = new SqlDirectoryOptions(connectionString, "BenchmarkDirectory");
            Analyzer = new StandardAnalyzer(AppLuceneVersion);
        }
        private static SqlIndexOutput GetSutObject(Mock <IDatabaseLuceneOperator> sqlOperator)
        {
            var options = new SqlDirectoryOptions(
                UnitTest,
                UnitTest)
            {
                BlockSize = UnitTestBlockSize
            };

            return(new SqlIndexOutput(options, sqlOperator.Object, new Node {
                Id = UnitTestId, Name = UnitTest
            }));
        }
Esempio n. 3
0
        public LuceneStorageFixture()
        {
            const string connectionString = "server=localhost;port=3306;database=lucene;uid=root;password=password;Allow User Variables=True;";

            Options = new SqlDirectoryOptions(connectionString, "TestDirectory");

            const LuceneVersion appLuceneVersion = LuceneVersion.LUCENE_48;

            MySqlOperator = MySqlLuceneOperator.Create(Options);

            Directory = new LuceneSqlDirectory(Options, MySqlOperator);

            Analyzer = new StandardAnalyzer(appLuceneVersion);

            Writer = new IndexWriter(Directory, new IndexWriterConfig(appLuceneVersion, Analyzer));
        }
Esempio n. 4
0
        public static void Main(string[] args)
        {
            const string connectionString = "server=localhost;port=3306;database=lucene;uid=root;password=password;Allow User Variables=True;";

            var options = new SqlDirectoryOptions(connectionString, "ExampleDirectory");

            using var mySqlOperator = MySqlLuceneOperator.Create(options);

            using var directory = new LuceneSqlDirectory(options, mySqlOperator);

            using var analyzer = new StandardAnalyzer(LuceneVersion.LUCENE_48);

            using var writer = new IndexWriter(directory, new IndexWriterConfig(LuceneVersion.LUCENE_48, analyzer));

            var source = new
            {
                Name           = "Kermit the Frog",
                FavoritePhrase = "The quick brown fox jumps over the lazy dog"
            };

            var doc = new Document
            {
                new StringField(
                    "name",
                    source.Name,
                    Field.Store.YES),
                new TextField(
                    "favoritePhrase",
                    source.FavoritePhrase,
                    Field.Store.YES)
            };

            writer.AddDocument(doc);

            writer.Flush(false, false);

            var phrase = new MultiPhraseQuery
            {
                new Term("favoritePhrase", "brown"),
                new Term("favoritePhrase", "fox")
            };

            var searcher = new IndexSearcher(writer.GetReader(true));

            var result = searcher.Search(phrase, 20);
        }
        private static SqlIndexInput GetSutObject()
        {
            var sqlOperator = new Mock <IDatabaseLuceneOperator>();

            SetupGetBlock(sqlOperator, 0, new byte[] { 1, 1, 1 });
            SetupGetBlock(sqlOperator, 1, new byte[] { 2, 2, 2 });
            SetupGetBlock(sqlOperator, 2, new byte[] { 3, 3, 3 });
            SetupGetBlock(sqlOperator, 3, new byte[] { 4, 3, 3 });

            var options = new SqlDirectoryOptions(
                UnitTest,
                UnitTest)
            {
                BlockSize = UnitTestBlockSize
            };

            return(new SqlIndexInput(options, sqlOperator.Object, new Node {
                Size = 10, Name = UnitTest, Id = UnitTestId
            }, 0, 10, 3));
        }
        public static SqlServerLuceneOperator Create(SqlDirectoryOptions options)
        {
            var connection = new SqlConnection(options.ConnectionString);

            try
            {
                connection.Open();

                var sqlOperator = new SqlServerLuceneOperator(options, connection);

                sqlOperator.SetupTables();

                return(sqlOperator);
            }
            catch (Exception ex)
            {
                connection.Dispose();

                throw new LuceneSqlException("Failed to create MySql Operator", ex);
            }
        }
 private SqlServerLuceneOperator(SqlDirectoryOptions options, SqlConnection connection)
 {
     _options    = options;
     _connection = connection;
 }
 private MySqlLuceneOperator(SqlDirectoryOptions options, MySqlConnection connection)
 {
     _options    = options;
     _connection = connection;
 }
 private PostgreSqlLuceneOperator(SqlDirectoryOptions options, NpgsqlConnection connection)
 {
     _options    = options;
     _connection = connection;
 }