-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathObjectReference.cs
More file actions
80 lines (68 loc) · 1.97 KB
/
ObjectReference.cs
File metadata and controls
80 lines (68 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Collections.Generic;
using Waher.Persistence.Attributes;
namespace Waher.Persistence.FullTextSearch
{
/// <summary>
/// Contains a reference to an indexed object.
/// </summary>
[CollectionName("FullTextSearchObjects")]
[TypeName(TypeNameSerialization.None)]
[Index("IndexCollection", "Index")]
[Index("Collection", "ObjectInstanceId")]
public class ObjectReference
{
/// <summary>
/// Contains a reference to an indexed object.
/// </summary>
public ObjectReference()
{
}
/// <summary>
/// Object ID of reference object.
/// </summary>
[ObjectId]
public string ObjectId { get; set; }
/// <summary>
/// Collection of full-text-search index.
/// </summary>
public string IndexCollection { get; set; }
/// <summary>
/// Name of collection hosting object.
/// </summary>
public string Collection { get; set; }
/// <summary>
/// Object ID of object instance.
/// </summary>
public object ObjectInstanceId { get; set; }
/// <summary>
/// Reference number to use in full-text-index.
/// </summary>
public ulong Index { get; set; }
/// <summary>
/// Token count in document.
/// </summary>
public TokenCount[] Tokens { get; set; }
/// <summary>
/// When object was indexed.
/// </summary>
public DateTime Indexed { get; set; }
/// <summary>
/// Tries to get a specific token count.
/// </summary>
/// <param name="Token">Token</param>
/// <param name="Count">Count, if found.</param>
/// <returns>If the corresponding token was found.</returns>
public bool TryGetCount(string Token, out TokenCount Count)
{
if (this.tokensByName is null)
{
this.tokensByName = new Dictionary<string, TokenCount>(StringComparer.InvariantCultureIgnoreCase);
foreach (TokenCount TokenCount in this.Tokens)
this.tokensByName[TokenCount.Token] = TokenCount;
}
return this.tokensByName.TryGetValue(Token, out Count);
}
private Dictionary<string, TokenCount> tokensByName = null;
}
}