-
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
6 changed files
with
146 additions
and
3 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/DotJEM.Json.Index2.Contexts.Test/DotJEM.Json.Index2.Contexts.Test.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,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<Import Project="..\DotJEM.Json.Index2.common.props" /> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<GeneratePackageOnBuild>False</GeneratePackageOnBuild> | ||
<GenerateDocumentationFile>False</GenerateDocumentationFile> | ||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" /> | ||
<PackageReference Include="NUnit" Version="3.13.3" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\DotJEM.Json.Index2.Contexts\DotJEM.Json.Index2.Contexts.csproj" /> | ||
<ProjectReference Include="..\DotJEM.Json.Index2\DotJEM.Json.Index2.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
48 changes: 48 additions & 0 deletions
48
src/DotJEM.Json.Index2.Contexts.Test/LuceneIndexContextTest.cs
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,48 @@ | ||
using DotJEM.Json.Index2.Documents.Fields; | ||
using DotJEM.Json.Index2.IO; | ||
using DotJEM.Json.Index2.Searching; | ||
using DotJEM.Json.Index2.Storage; | ||
using Lucene.Net.Analysis.Standard; | ||
using Lucene.Net.Index; | ||
using Lucene.Net.Search; | ||
using Newtonsoft.Json.Linq; | ||
using NUnit.Framework; | ||
|
||
namespace DotJEM.Json.Index2.Contexts.Test; | ||
|
||
public class LuceneIndexContextTest | ||
{ | ||
[Test] | ||
public async Task SayHello_ReturnsHello() | ||
{ | ||
IJsonIndexContextBuilder builder = new JsonIndexContextBuilder(); | ||
builder | ||
.ByDefault(x => x.UsingMemmoryStorage().Build()); | ||
builder | ||
.For("IndexName", b => b.UsingStorage(new RamJsonIndexStorage()).Build()); | ||
|
||
|
||
|
||
IJsonIndexContext context = builder.Build(); | ||
context.Open("IndexName"); | ||
|
||
IJsonIndex index = new JsonIndexBuilder("myIndex") | ||
.UsingMemmoryStorage() | ||
.WithAnalyzer(cfg => new StandardAnalyzer(cfg.Version)) | ||
.WithFieldResolver(new FieldResolver("uuid", "type")) | ||
.Build(); | ||
|
||
IJsonIndexWriter writer = index.CreateWriter(); | ||
writer.Create(JObject.FromObject(new { uuid = Guid.NewGuid(), type = "CAR" })); | ||
writer.Create(JObject.FromObject(new { uuid = Guid.NewGuid(), type = "CAR" })); | ||
writer.Create(JObject.FromObject(new { uuid = Guid.NewGuid(), type = "CAR" })); | ||
writer.Create(JObject.FromObject(new { uuid = Guid.NewGuid(), type = "CAR" })); | ||
writer.Create(JObject.FromObject(new { uuid = Guid.NewGuid(), type = "CAR" })); | ||
writer.Commit(); | ||
|
||
IJsonIndexSearcher? searcher = index.CreateSearcher(); | ||
int count = searcher.Search(new TermQuery(new Term("type", "car"))).Count(); | ||
//int count = searcher.Search(new MatchAllDocsQuery()).Count(); | ||
Assert.AreEqual(5, count); | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
src/DotJEM.Json.Index2.Contexts/Sharding/ShardingJsonIndex.cs
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,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using DotJEM.Json.Index2.Configuration; | ||
using DotJEM.Json.Index2.IO; | ||
using DotJEM.Json.Index2.Searching; | ||
using DotJEM.Json.Index2.Storage; | ||
using DotJEM.ObservableExtensions.InfoStreams; | ||
|
||
namespace DotJEM.Json.Index2.Contexts.Sharding | ||
{ | ||
internal class ShardingJsonIndex : IJsonIndex | ||
{ | ||
public IJsonIndexSearcher CreateSearcher() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public IInfoStream InfoStream { get; } | ||
public IJsonIndexStorageManager Storage { get; } | ||
public IJsonIndexConfiguration Configuration { get; } | ||
public IIndexWriterManager WriterManager { get; } | ||
public IIndexSearcherManager SearcherManager { get; } | ||
|
||
public IJsonIndexWriter CreateWriter() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void Close() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
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