Skip to content

Commit bbc436a

Browse files
committed
Cherry picks docfx to master
1 parent 9c1b147 commit bbc436a

31 files changed

+2303
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Deploy DocFX with GitHub Pages dependencies preinstalled
2+
3+
on:
4+
# Runs on pushes targeting the default branch
5+
push:
6+
branches: ["feature/docfx"]
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
# Allow one concurrent deployment
18+
concurrency:
19+
group: "pages"
20+
cancel-in-progress: true
21+
22+
jobs:
23+
# Build job
24+
build:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v3
29+
- name: Setup Github Pages
30+
uses: actions/configure-pages@v3
31+
32+
- name: Build DocFX Site
33+
uses: VakuWare/docfx-pdf-action@v1.4.0
34+
with:
35+
args: docs/v2/docfx.json
36+
- name: Upload docfx built site artifact
37+
uses: actions/upload-pages-artifact@v1
38+
with:
39+
path: docs/v2/_site
40+
41+
# Deployment job
42+
deploy:
43+
environment:
44+
name: github-pages
45+
url: ${{ steps.deployment.outputs.page_url }}
46+
runs-on: ubuntu-latest
47+
needs: build
48+
steps:
49+
- name: Deploy to GitHub Pages
50+
id: deployment
51+
uses: actions/deploy-pages@v1

docs/v2/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
###############
2+
# folder #
3+
###############
4+
/**/DROP/
5+
/**/TEMP/
6+
/**/packages/
7+
/**/bin/
8+
/**/obj/
9+
_site

docs/v2/404.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
permalink: /404.html
3+
layout: default
4+
---
5+
6+
<style type="text/css" media="screen">
7+
.container {
8+
margin: 10px auto;
9+
max-width: 600px;
10+
text-align: center;
11+
}
12+
h1 {
13+
margin: 30px 0;
14+
font-size: 4em;
15+
line-height: 1;
16+
letter-spacing: -1px;
17+
}
18+
</style>
19+
20+
<div class="container">
21+
<h1>404</h1>
22+
23+
<p><strong>Page not found :(</strong></p>
24+
<p>The requested page could not be found.</p>
25+
</div>

docs/v2/404.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
layout: page
3+
title: 404 Error
4+
tagline: Ah snap! We could not find what you are looking for!
5+
permalink: /404.html
6+
---
7+
8+
Try got get back to the Home Page and start over!
9+
10+
[Go to the Home Page]({{ '/' | absolute_url }})

docs/v2/android-chrome-192x192.png

18.1 KB
Loading

docs/v2/android-chrome-384x384.png

43.9 KB
Loading

docs/v2/api/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
###############
2+
# temp file #
3+
###############
4+
*.yml
5+
.manifest

docs/v2/api/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
uid: apidocsindex
3+
---
4+
# Examine V3 API Documentation
5+
6+
API documentation is automatically generated.
7+
8+
_**Tip**: There are many unit tests in the source code that can be used as Examples of how to do things. There is also a test web project that has plenty of examples of how to configure indexes and search them._

docs/v2/articles/configuration.md

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
---
2+
layout: page
3+
title: Configuration
4+
permalink: /configuration
5+
uid: configuration
6+
order: 1
7+
---
8+
9+
Configuration
10+
===
11+
12+
An index can be configured in many ways including different configurations per field such as how those values are analyzed, indexed, tokenized ... basically how the data is stored and retrieved. This is done via Examine ["Value Types"](#value-types).
13+
14+
_**Note**: This documentation refers to using Lucene based indexes in Examine (the default index type shipped in Examine)._
15+
16+
## Field definitions
17+
18+
A Field Definition is a mapping of a field name to a ["Value Types"](#value-types). By default all fields are mapped to the default Value Type: [`FieldDefinitionTypes.FullText`](xref:Examine.FieldDefinitionTypes#Examine_FieldDefinitionTypes_FullText).
19+
20+
You can map a field to any value type when configuring the index.
21+
22+
### IConfigureNamedOptions
23+
24+
Configuration of Examine indexes is done with [.NET's Options pattern](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-5.0). For Examine, this is done with named options: [`IConfigureNamedOptions`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.options.iconfigurenamedoptions-1).
25+
26+
There are several options that can be configured, the most common ones are:
27+
28+
* __FieldDefinitions__ _[`FieldDefinitionCollection`](xref:Examine.FieldDefinitionCollection)_ - Manages the mappings between a field name and it's index value type
29+
* __Analyzer__ _`Analyzer`_ - The default Lucene Analyzer to use for each field (default = [`StandardAnalyzer`](https://lucenenet.apache.org/docs/4.8.0-beta00016/api/analysis-common/Lucene.Net.Analysis.Standard.StandardAnalyzer.html))
30+
* __Validator__ _[`IValueSetValidator`]([`IValueSetValidator`](xref:Examine.IValueSetValidator))_ - Used to validate a value set to be indexed, if validation fails it will not be indexed
31+
* __[IndexValueTypesFactory](xref:Examine.Lucene.IFieldValueTypeFactory)__ _`IReadOnlyDictionary<string, IFieldValueTypeFactory>`_ - Allows you to define custom Value Types
32+
33+
```cs
34+
/// <summary>
35+
/// Configure Examine indexes using .NET IOptions
36+
/// </summary>
37+
public sealed class ConfigureIndexOptions : IConfigureNamedOptions<LuceneDirectoryIndexOptions>
38+
{
39+
public void Configure(string name, LuceneDirectoryIndexOptions options)
40+
{
41+
switch (name)
42+
{
43+
case "MyIndex":
44+
// Set the "Price" field to map to the 'Double' value type.
45+
options.FieldDefinitions.AddOrUpdate(
46+
new FieldDefinition("Price", FieldDefinitionTypes.Double));
47+
break;
48+
}
49+
}
50+
51+
public void Configure(LuceneDirectoryIndexOptions options)
52+
=> Configure(string.Empty, options);
53+
}
54+
```
55+
56+
### After construction
57+
58+
You can modify the field definitions [FieldDefinitionCollection](xref:Examine.FieldDefinitionCollection) for an index after it is constructed by using any of the following methods:
59+
60+
* `myIndex.FieldDefinitionCollection.TryAdd`
61+
* `myIndex.FieldDefinitionCollection.AddOrUpdate`
62+
* `myIndex.FieldDefinitionCollection.GetOrAdd`
63+
64+
These modifications __must__ be done before any indexing or searching is executed.
65+
66+
### Add a field value type after construction
67+
68+
It is possible to add custom field value types after the construction of the index, but this must be done before the index is used. Some people may prefer this method of adding custom field value types. Generally, these should be modified directly after the construction of the index.
69+
70+
```cs
71+
// Create the index with all of the defaults
72+
var myIndex = new LuceneIndex(
73+
"MyIndex",
74+
new SimpleFSDirectory(new DirectoryInfo("C:\\TestIndexes")));
75+
76+
// Add a custom field value type
77+
myIndex.FieldValueTypeCollection.ValueTypeFactories
78+
.TryAdd(
79+
"phonenumber",
80+
name => new GenericAnalyzerFieldValueType(
81+
name,
82+
new PhoneNumberAnalyzer()));
83+
84+
// Map a field to use the custom field value type
85+
myIndex.FieldDefinitionCollection.TryAdd(
86+
new FieldDefinition("Phone", "phonenumber"));
87+
```
88+
89+
## Value types
90+
91+
Value types are responsible for:
92+
93+
* Defining a field name and if the field should be sortable, the field to store the sortable data
94+
* Adding a field value to an index document
95+
* Configuring how the value will be stored in the index
96+
* Configuring the analyzer for the field
97+
* Generating the Query for the field
98+
99+
These are the default field value types provided with Examine. Each value type can be resolved from the static class [`Examine.FieldDefinitionTypes`](xref:Examine.FieldDefinitionTypes) (i.e. [`Examine.FieldDefinitionTypes.FullText`](xref:Examine.FieldDefinitionTypes#Examine_FieldDefinitionTypes_FullText)).
100+
101+
| Value Type | Description | Sortable |
102+
|----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|
103+
| FullText | __Default__.<br />The field will be indexed with the index's <br />default Analyzer without any sortability. <br />Generally this is fine for normal text searching. ||
104+
| FullTextSortable | Will be indexed with FullText but also <br />enable sorting on this field for search results. <br />_FullText sortability adds additional overhead <br />since it requires an additional index field._ ||
105+
| Integer | Stored as a numerical structure. ||
106+
| Float | Stored as a numerical structure. ||
107+
| Double | Stored as a numerical structure. ||
108+
| Long | Stored as a numerical structure. ||
109+
| DateTime | Stored as a DateTime, <br />represented by a numerical structure. ||
110+
| DateYear | Just like DateTime but with <br />precision only to the year. ||
111+
| DateMonth | Just like DateTime but with <br />precision only to the month. ||
112+
| DateDay | Just like DateTime but with <br />precision only to the day. ||
113+
| DateHour | Just like DateTime but with <br />precision only to the hour. ||
114+
| DateMinute | Just like DateTime but with <br />precision only to the minute. ||
115+
| EmailAddress | Uses custom analyzers for dealing <br />with email address searching. ||
116+
| InvariantCultureIgnoreCase | Uses custom analyzers for dealing with text so it<br /> can be searched on regardless of the culture/casing. ||
117+
| Raw | Will be indexed without analysis, searching will<br /> only match with an exact value. ||
118+
119+
### Custom field value types
120+
121+
A field value type is defined by [`IIndexFieldValueType`](xref:Examine.Lucene.Indexing.IIndexFieldValueType)
122+
123+
_**Tip**: There are many implementations of IIndexFieldValueType in the source code to use as examples/reference._
124+
125+
A common base class that can be used for field value types is: [`IndexFieldValueTypeBase`](xref:Examine.Lucene.Indexing.IndexFieldValueTypeBase).
126+
127+
A common implementation that can be used for field value types for custom Analyzers is: [`GenericAnalyzerFieldValueType`](xref:Examine.Lucene.Indexing.GenericAnalyzerFieldValueType).
128+
129+
#### Example - Phone Number
130+
131+
A phone number stored in Lucene could require a custom analyzer to index and search it properly. So the best way to set this up in Examine would be to have a custom field value type for it. Since this field value type doesn't need to do anything more fancy than to provide a custom analyzer, we can create it with the [`GenericAnalyzerFieldValueType`](xref:Examine.Lucene.Indexing.GenericAnalyzerFieldValueType).
132+
133+
```cs
134+
/// <summary>
135+
/// Configure Examine indexes using .NET IOptions
136+
/// </summary>
137+
public sealed class ConfigureIndexOptions : IConfigureNamedOptions<LuceneDirectoryIndexOptions>
138+
{
139+
private readonly ILoggerFactory _loggerFactory;
140+
141+
public ConfigureIndexOptions(ILoggerFactory loggerFactory)
142+
=> _loggerFactory = loggerFactory;
143+
144+
public void Configure(string name, LuceneDirectoryIndexOptions options)
145+
{
146+
switch (name)
147+
{
148+
case "MyIndex":
149+
// Create a dictionary for custom value types.
150+
// They keys are the value type names.
151+
options.IndexValueTypesFactory = new Dictionary<string, IFieldValueTypeFactory>
152+
{
153+
// Create a phone number value type using the GenericAnalyzerFieldValueType
154+
// to pass in a custom analyzer. As an example, it could use Examine's
155+
// PatternAnalyzer to pass in a phone number pattern to match.
156+
["phone"] = new DelegateFieldValueTypeFactory(name =>
157+
new GenericAnalyzerFieldValueType(
158+
name,
159+
_loggerFactory,
160+
new PatternAnalyzer(@"\d{3}\s\d{3}\s\d{4}", 0)))
161+
};
162+
163+
// Add the field definition for a field called "phone" which maps
164+
// to a Value Type called "phone" defined above.
165+
options.FieldDefinitions.AddOrUpdate(new FieldDefinition("phone", "phone"));
166+
break;
167+
}
168+
}
169+
170+
public void Configure(LuceneDirectoryIndexOptions options)
171+
=> throw new NotImplementedException("This is never called and is just part of the interface");
172+
}
173+
```
174+
175+
The above creates a custom field value type using a custom analyzer and maps the "Phone" field to use this value type.
176+
177+
## ValueSet validators
178+
179+
An [`IValueSetValidator`](xref:Examine.IValueSetValidator) is a simple interface:
180+
181+
```cs
182+
public interface IValueSetValidator
183+
{
184+
ValueSetValidationResult Validate(ValueSet valueSet);
185+
}
186+
```
187+
188+
That returns an result [`ValueSetValidationResult`](xref:Examine.ValueSetValidationResult) with an enum of [`ValueSetValidationStatus`](xref:Examine.ValueSetValidationStatus) values:
189+
190+
* `Valid` - The ValueSet is valid and will be indexed
191+
* `Failed` - The ValueSet was invalid and will not be indexed
192+
* `Filtered` - The ValueSet has been filtered/modified by the validator and will be indexed
193+
194+
Examine only has one implementation: [`ValueSetValidatorDelegate`](xref:Examine.Lucene.Providers.ValueSetValidatorDelegate) which can be used by developers as a simple way to create a validator based on a callback, else developers can implement this interface if required. By default, no ValueSet validation is done with Examine.

0 commit comments

Comments
 (0)