-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
181 additions
and
30 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
Lucene.Net.Sql.MySql.Example/Lucene.Net.Sql.MySql.Example.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Lucene.Net.Analysis.Common" Version="4.8.0-beta00012" /> | ||
<PackageReference Include="Lucene.Net.Sql.MySql" Version="0.0.3-alpha" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using Lucene.Net.Analysis.Standard; | ||
using Lucene.Net.Documents; | ||
using Lucene.Net.Index; | ||
using Lucene.Net.Search; | ||
using Lucene.Net.Util; | ||
|
||
namespace Lucene.Net.Sql.MySql.Example | ||
{ | ||
// dotnet pack -c Release -o out --version-suffix 0.0.3-alpha Lucene.Net.Sql.MySql/Lucene.Net.Sql.MySql.csproj | ||
public class Program | ||
{ | ||
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<configuration> | ||
<packageSources> | ||
<add key="repositoryPath" value="./out" /> | ||
</packageSources> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters