-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update references and editor config * V5.0.0 dynamic fields (#70) * Search results phrases working with dynamic fields * Added support for child object dynamic field providers * Handle serialization of dynamic fields * Throw error on deserialization of earlier index if fields not found * Updated documentation
- Loading branch information
1 parent
a908e8c
commit 0ddbcf7
Showing
74 changed files
with
2,848 additions
and
531 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
11 changes: 11 additions & 0 deletions
11
docs/content/en/docs/Reference/Serialization format/PreVersion5.md
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,11 @@ | ||
--- | ||
title: "V2-4 Serialization File Format" | ||
linkTitle: "V2-4 Serialization File Format" | ||
date: 2023-07-02 | ||
description: > | ||
Documentation for older serialization formats. | ||
--- | ||
|
||
## Version 4 (v4.0.0) | ||
|
||
![LIFTI Serialization Format](../../../../images/v2-serialization.svg) |
17 changes: 17 additions & 0 deletions
17
docs/content/en/docs/Reference/Serialization format/_index.md
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,17 @@ | ||
--- | ||
title: "Serialization File Format" | ||
linkTitle: "Serialization File Format" | ||
date: 2023-07-04 | ||
description: > | ||
The current serialization format is version 5. | ||
--- | ||
|
||
## Version 5 (v5.0.0) | ||
|
||
![LIFTI Serialization Format](../../../images/v5-serialization.svg) | ||
|
||
Notes: | ||
|
||
- Versions 2 to 4 are readable as a one-time conversion but always written back as version 5. | ||
- Int32s are written as *positive* values using 7-bit encoding. This means that the maximum value is 2,147,483,647, apart from Int32s written by the `IntFormatterKeySerializer` which can't make the assumption that the value is always positive. For these, values are written using zig-zag encoding. | ||
- New in version 5 is the list of fields in the index. This is used upon deserialization to rehydrate the dynamic fields and ensure that the field names in the index being deserialized into are mapped correctly to fields in the serialized index. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
title: "Field Information" | ||
linkTitle: "Field Information" | ||
weight: 5 | ||
description: > | ||
You can query the index to get information about the fields that have been indexed. | ||
--- | ||
|
||
A `FullTextIndex` class exposes a `FieldLookup` property of type `IIndexedFieldLookup` that can be used to query the index for | ||
information about the fields that have been indexed. | ||
|
||
`IIndexedFieldLookup` exposes the following methods: | ||
|
||
## `DefaultField` | ||
|
||
The id of the default field used when an `IFullTextIndex{T}.AddAsync(T, string, System.Threading.CancellationToken)` overload has been used, as opposed to indexing text read from properties of object. | ||
|
||
## `GetFieldForId(byte id)` | ||
|
||
Gets the configured name for a field id. | ||
|
||
## `GetFieldInfo(string fieldName)` | ||
|
||
Gets the configuration required for indexing a named field, including the `Tokenization.TextExtraction.ITextExtractor` and `Tokenization.IIndexTokenizer` instances to use when processing the field's text. | ||
|
||
### `IndexedFieldDetails` | ||
|
||
This abstract class contains information about a field that has been configured for indexing. | ||
|
||
#### Properties | ||
|
||
- **Id**: Gets the id of the field. | ||
- **Name**: Gets the name of the field. | ||
- **ObjectType**: Gets the type of the object the field is registered for. | ||
- **FieldKind**: Gets the kind of field this instance represents, either `FieldKind.Static` or `FieldKind.Dynamic`. | ||
- **TextExtractor**: Gets the `ITextExtractor` used to extract sections of text from this field. | ||
- **Tokenizer**: Gets the `IIndexTokenizer` that should be used when tokenizing text for the field. | ||
- **Thesaurus**: Gets the `IThesaurus` that should be used to expand tokens when processing text for this field. | ||
- **DynamicFieldReaderName**: Gets the name of the dynamic field reader that generated this field. If this field is not a dynamic field, this will be `null`. | ||
|
||
#### Methods | ||
|
||
- **ReadAsync(object item, CancellationToken cancellationToken)**: Reads the text for the field from the specified item. The item must be of the type specified by the `ObjectType` property. | ||
|
||
|
||
## `IsKnownField(Type objectType, string fieldName)` | ||
|
||
Returns `true` if the given field name is known to the index and associated to the given object type, whether statically defined at index creation, or dynamically registered during indexing. | ||
|
||
## `AllFieldNames` | ||
|
||
Gets the names of all fields configured in the index, including any dynamic fields that have been registered during the indexing of objects. |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,72 @@ | ||
using Lifti; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace TestConsole | ||
{ | ||
public class DynamicFieldsSample : SampleBase | ||
{ | ||
public class TestObject | ||
{ | ||
public TestObject(int id, string details, IDictionary<string, string> data) | ||
{ | ||
this.Id = id; | ||
this.Details = details; | ||
this.Data = data; | ||
} | ||
|
||
public int Id { get; set; } | ||
public string Details { get; } | ||
public IDictionary<string, string> Data { get; set; } | ||
} | ||
|
||
public override async Task RunAsync() | ||
{ | ||
Console.WriteLine("Creating an index that has dynamically registered fields for an object."); | ||
Console.WriteLine("Only one field, Details, is statically registered when the index is created."); | ||
|
||
var objects = new Dictionary<int, TestObject> | ||
{ | ||
{ | ||
1, | ||
new TestObject( | ||
1, | ||
"Some details", | ||
new Dictionary<string, string> { { "Name", "Joe Bloggs" }, { "Profile", "Just placeholder text here" } }) | ||
}, | ||
{ | ||
2, | ||
new TestObject( | ||
2, | ||
"Chillin with orange juice", | ||
new Dictionary<string, string> { { "Name", "Just Bob" }, { "FavouriteExercise", "Jumping jacks" } }) | ||
} | ||
}; | ||
|
||
var index = new FullTextIndexBuilder<int>() | ||
.WithObjectTokenization<TestObject>(o => o | ||
.WithKey(c => c.Id) | ||
.WithField("Details", x => x.Details) | ||
.WithDynamicFields("Data", c => c.Data) | ||
) | ||
.Build(); | ||
|
||
await index.AddRangeAsync(objects.Values); | ||
|
||
var results = RunSearchAsync( | ||
index, | ||
"ju*", | ||
i => objects[i], | ||
@"Words beginning with 'ju' are contained across 4 fields, 3 of which will have been dynamically registered"); | ||
|
||
Console.WriteLine("Fields known to the index:"); | ||
foreach (var field in index.FieldLookup.AllFieldNames) | ||
{ | ||
Console.WriteLine($"{field} - Field kind:{index.FieldLookup.GetFieldInfo(field).FieldKind}"); | ||
} | ||
|
||
WaitForEnterToReturnToMenu(); | ||
} | ||
} | ||
} |
Oops, something went wrong.