This repository was archived by the owner on Mar 15, 2020. It is now read-only.
-
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.
Merge pull request #7 from j2ghz/search
Search
- Loading branch information
Showing
16 changed files
with
202 additions
and
62 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
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 |
---|---|---|
@@ -1,24 +1,34 @@ | ||
module Quests.Types | ||
|
||
open Shared | ||
open Elmish | ||
|
||
type Page = | ||
| Home | ||
| SelectedSource of source: Source | ||
| QuestLine of Source * int | ||
| Search of Source * string | ||
|
||
type Msg = | ||
//Sources | ||
| LoadSources | ||
| LoadSourcesFinished of Source list | ||
| LoadSourcesError of exn | ||
//QuestLines | ||
| LoadQuestLines of Source | ||
| LoadQuestLinesFinished of Shared.QuestLineInfo list | ||
| LoadQuestLinesError of exn | ||
//QuestLine | ||
| LoadQuestLine of Source * int | ||
| LoadQuestLineFinished of Shared.QuestLine | ||
| LoadQuestLineError of exn | ||
//Search | ||
| LoadSearchResults of Source * string | ||
| LoadSearchResultsFinished of QuestSearchResult list | ||
| LoadSearchResultsError of exn | ||
|
||
type State = | ||
{ Sources: Shared.Source list Remote | ||
QuestLines: Shared.QuestLineInfo list Remote | ||
QuestLine: Shared.QuestLine Remote } | ||
QuestLine: Shared.QuestLine Remote | ||
SearchResults: Shared.QuestSearchResult list Remote } |
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
1 change: 0 additions & 1 deletion
1
src/Server/SampleData/DefaultQuests-2.0.7.6c-dev-cleaned-minified.json
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
src/Server/SampleData/DefaultQuests-2.0.7.6d-dev-cleaned-minified.json
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
src/Server/SampleData/DefaultQuests-2.0.7.6e-dev-cleaned-minified.json
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
src/Server/SampleData/DefaultQuests-2.0.7.7-dev-cleaned-minified.json
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
module Search | ||
|
||
open Lucene.Net.Util | ||
open Lucene.Net.Store | ||
open System.IO | ||
open Lucene.Net.Index | ||
open Shared | ||
open Lucene.Net.Documents | ||
open Lucene.Net.Search | ||
open Lucene.Net.QueryParsers.Simple | ||
open System.Collections.Generic | ||
open System.Linq | ||
|
||
[<Literal>] | ||
let VERSION = LuceneVersion.LUCENE_48 | ||
|
||
let questSearch quests = | ||
let storage = new RAMDirectory() //new MMapDirectory(DirectoryInfo("./lucene-index")) | ||
let analyzer = new Lucene.Net.Analysis.Standard.StandardAnalyzer(VERSION) | ||
let indexConfig = IndexWriterConfig(VERSION, analyzer) | ||
let writer = new IndexWriter(storage, indexConfig) | ||
|
||
let questToDoc (quest: Quest) = | ||
let doc = Document() | ||
doc.AddInt32Field("ID", quest.Id, Field.Store.YES) |> ignore | ||
doc.AddTextField("Name", quest.Name, Field.Store.YES) |> ignore | ||
doc.AddTextField("Description", quest.Description, Field.Store.YES) |> ignore | ||
doc :> IIndexableField seq | ||
|
||
quests | ||
|> List.map questToDoc | ||
|> writer.AddDocuments | ||
do writer.Flush(true, true) | ||
|
||
let reader = writer.GetReader(false) | ||
let searcher = IndexSearcher(reader) | ||
|
||
let parser = | ||
SimpleQueryParser | ||
(analyzer, | ||
dict | ||
[ "Name", 0.5f | ||
"Description", 0.5f ]) | ||
|
||
let getDoc id = | ||
let doc = searcher.Doc(id) | ||
{ Id = doc.GetField("ID").GetInt32Value().GetValueOrDefault() | ||
Name = doc.Get("Name") | ||
Description = doc.Get("Description") } | ||
|
||
fun searchText -> | ||
let query = parser.Parse(searchText) | ||
searcher.Search(query, 20).ScoreDocs | ||
|> Array.toList | ||
|> List.sortBy (fun d -> d.Score) | ||
|> List.map (fun d -> d.Doc |> getDoc) |
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 |
---|---|---|
@@ -1,14 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.0</TargetFramework> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<None Include="paket.references" /> | ||
<None Include="SampleData/*" CopyToOutputDirectory="Always" /> | ||
<Compile Include="../Shared/Shared.fs" /> | ||
<Compile Include="Parsers.fs" /> | ||
<Compile Include="Server.fs" /> | ||
</ItemGroup> | ||
<Import Project="..\..\.paket\Paket.Restore.targets" /> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.0</TargetFramework> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<None Include="paket.references" /> | ||
<None Include="SampleData/*" /> | ||
<Compile Include="../Shared/Shared.fs" /> | ||
<Compile Include="Parsers.fs" /> | ||
<Compile Include="Search.fs" /> | ||
<Compile Include="Server.fs" /> | ||
</ItemGroup> | ||
<Import Project="..\..\.paket\Paket.Restore.targets" /> | ||
</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
Oops, something went wrong.