-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #298 from nikcio/demo/update-project
Updated demo project
- Loading branch information
Showing
122 changed files
with
54,992 additions
and
44,090 deletions.
There are no files selected for viewing
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,12 @@ | ||
<Router AppAssembly="@typeof(App).Assembly"> | ||
<Found Context="routeData"> | ||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> | ||
<FocusOnNavigate RouteData="@routeData" Selector="h1" /> | ||
</Found> | ||
<NotFound> | ||
<PageTitle>Not found</PageTitle> | ||
<LayoutView Layout="@typeof(MainLayout)"> | ||
<p role="alert">Sorry, there's nothing at this address.</p> | ||
</LayoutView> | ||
</NotFound> | ||
</Router> |
This file was deleted.
Oops, something went wrong.
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,103 @@ | ||
using System.Diagnostics; | ||
using Examine.Lucene.Providers; | ||
using Examine.Search; | ||
using Examine.Web.Demo.Controllers; | ||
using Examine.Web.Demo.Data.Models; | ||
using Lucene.Net.Search; | ||
|
||
namespace Examine.Web.Demo.Data | ||
{ | ||
public class IndexService | ||
{ | ||
private readonly IExamineManager _examineManager; | ||
private readonly BogusDataService _bogusDataService; | ||
|
||
public IndexService(IExamineManager examineManager, BogusDataService bogusDataService) { | ||
_examineManager = examineManager; | ||
_bogusDataService = bogusDataService; | ||
} | ||
|
||
public void RebuildIndex(string indexName, int dataSize) | ||
{ | ||
var index = GetIndex(indexName); | ||
|
||
index.CreateIndex(); | ||
|
||
var data = _bogusDataService.GenerateData(dataSize); | ||
|
||
index.IndexItems(data); | ||
} | ||
|
||
public IndexInformation GetIndexInformation(string indexName) | ||
{ | ||
var index = GetIndex(indexName); | ||
|
||
if (index is IIndexStats indexStats) | ||
{ | ||
var fields = indexStats.GetFieldNames(); | ||
return new IndexInformation( | ||
indexStats.GetDocumentCount(), | ||
fields.ToList()); | ||
} | ||
else | ||
{ | ||
throw new InvalidOperationException($"Failed to get index stats on {indexName}"); | ||
} | ||
} | ||
|
||
public void AddToIndex(string indexName, int dataSize) | ||
{ | ||
var index = GetIndex(indexName); | ||
|
||
var data = _bogusDataService.GenerateData(dataSize); | ||
|
||
index.IndexItems(data); | ||
} | ||
|
||
public IEnumerable<IIndex> GetAllIndexes() | ||
{ | ||
return _examineManager.Indexes; | ||
} | ||
|
||
public ISearchResults SearchNativeQuery(string indexName, string query) | ||
{ | ||
var index = GetIndex(indexName); | ||
|
||
var searcher = index.Searcher; | ||
var criteria = searcher.CreateQuery(); | ||
return criteria.NativeQuery(query).Execute(); | ||
} | ||
|
||
public ISearchResults SearchNativeQueryAcrossIndexes(string query) | ||
{ | ||
if (!_examineManager.TryGetSearcher("MultiIndexSearcher", out var multiIndexSearcher)) | ||
{ | ||
throw new InvalidOperationException("Failed to get MultiIndexSearcher"); | ||
} | ||
|
||
var searcher = multiIndexSearcher; | ||
var criteria = searcher.CreateQuery(); | ||
return criteria.NativeQuery(query).Execute(); | ||
} | ||
|
||
public ISearchResults GetAllIndexedItems(string indexName, int skip, int take) | ||
{ | ||
var index = GetIndex(indexName); | ||
|
||
var searcher = index.Searcher; | ||
var criteria = searcher.CreateQuery(); | ||
return criteria.All().Execute(QueryOptions.SkipTake(skip, take)); | ||
} | ||
|
||
private IIndex GetIndex(string indexName) | ||
{ | ||
if (!_examineManager.TryGetIndex(indexName, out var index)) | ||
{ | ||
throw new ArgumentException($"Index '{indexName}' not found"); | ||
} | ||
|
||
return index; | ||
} | ||
} | ||
|
||
} |
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,16 @@ | ||
namespace Examine.Web.Demo.Data.Models | ||
{ | ||
public class IndexInformation | ||
{ | ||
public IndexInformation(long documentCount, List<string> fields) | ||
{ | ||
DocumentCount = documentCount; | ||
Fields = fields; | ||
FieldCount = fields.Count; | ||
} | ||
|
||
public long DocumentCount { get; } | ||
public List<string> Fields { get; } | ||
public int FieldCount { get; set; } | ||
} | ||
} |
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 |
---|---|---|
@@ -1,40 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<OutputPath>bin\</OutputPath> | ||
<DefineConstants>TRACE;DEBUG;FULLDEBUG</DefineConstants> | ||
<CodeAnalysisRuleSet>SecurityRules.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>none</DebugType> | ||
<OutputPath>bin\</OutputPath> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
<IsPackable>false</IsPackable> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Remove="Examine\**" /> | ||
<Content Remove="Examine\**" /> | ||
<EmbeddedResource Remove="Examine\**" /> | ||
<None Remove="Examine\**" /> | ||
<PackageReference Include="Bogus" Version="34.0.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Examine.Core\Examine.Core.csproj" /> | ||
<ProjectReference Include="..\Examine.Host\Examine.csproj" /> | ||
<ProjectReference Include="..\Examine.Lucene\Examine.Lucene.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Bogus" Version="33.0.2" /> | ||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.5" /> | ||
<PackageReference Include="Lucene.Net.Analysis.Common" Version="4.8.0-beta00016" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Modernizr" Version="1.7" /> | ||
</ItemGroup> | ||
</Project> | ||
|
||
</Project> |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.