Skip to content

Commit 72325b7

Browse files
committed
Release 2.0.0
1 parent 66eb858 commit 72325b7

File tree

2 files changed

+60
-21
lines changed

2 files changed

+60
-21
lines changed

CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/) and this project adheres to [Semantic Versioning](https://semver.org/).
66

7+
## [2.0.0] - 2022-05-30
8+
### Added
9+
* Initial release of Search Extensions for Umbraco 9+
10+
711
## [1.5.1] - 2022-02-29
812
### Fixed
913
* `CreatePublishedQuery` returns content without templates and with `umbracoNaviHide` set
@@ -75,7 +79,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/) and this
7579
### Added
7680
* Initial release of Search Extensions for Umbraco 8.1
7781

78-
[Unreleased]: https://github.com/callumbwhyte/umbraco-search-extensions/compare/release-1.5.1...HEAD
82+
[Unreleased]: https://github.com/callumbwhyte/umbraco-search-extensions/compare/release-2.0.0...HEAD
83+
[2.0.0]: https://github.com/callumbwhyte/umbraco-search-extensions/compare/release-1.5.1...release-2.0.0
7984
[1.5.1]: https://github.com/callumbwhyte/umbraco-search-extensions/compare/release-1.5.0...release-1.5.1
8085
[1.5.0]: https://github.com/callumbwhyte/umbraco-search-extensions/compare/release-1.4.1...release-1.5.0
8186
[1.4.1]: https://github.com/callumbwhyte/umbraco-search-extensions/compare/release-1.4.0...release-1.4.1

README.md

+54-20
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
[![NuGet release](https://img.shields.io/nuget/v/Our.Umbraco.Extensions.Search.svg)](https://www.nuget.org/packages/Our.Umbraco.Extensions.Search/)
66
[![Our Umbraco project page](https://img.shields.io/badge/our-umbraco-orange.svg)](https://our.umbraco.com/packages/website-utilities/search-extensions/)
77

8-
_Looking for Search Extensions for **Umbraco 9**? Check the [v9/dev](https://github.com/callumbwhyte/umbraco-search-extensions/tree/v9/dev) branch._
8+
_Looking for Search Extensions for **Umbraco 8**? Check the [v8/dev](https://github.com/callumbwhyte/umbraco-search-extensions/tree/v8/dev) branch._
99

1010
## Getting started
1111

12-
This package is supported on Umbraco 8.1+.
12+
This package is supported on Umbraco 9+.
1313

1414
### Installation
1515

@@ -114,15 +114,27 @@ foreach (var result in query.Execute())
114114

115115
Search Extensions introduces several new field types into Examine – `json`, `list`, `UDI` and `picker` – to ensure Umbraco data is correctly indexed and queryable.
116116

117-
Defining which fields in the index use which types is done through the `IExamineManager`:
117+
Examine allows controlling an index's fields, field types, and [more](https://shazwazza.github.io/Examine/configuration#iconfigurenamedoptions), via [.NET's Named Options pattern](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options):
118118

119119
```
120-
if (examineManager.TryGetIndex("ExternalIndex", out IIndex index))
120+
public class ConfigureIndexOptions : IConfigureNamedOptions<LuceneDirectoryIndexOptions>
121121
{
122-
index.FieldDefinitionCollection.AddOrUpdate(new FieldDefinition("fieldName", "fieldType"));
122+
public void Configure(string name, LuceneDirectoryIndexOptions options)
123+
{
124+
if (name == "ExternalIndex")
125+
{
126+
options.FieldDefinitions.AddOrUpdate(new FieldDefinition("fieldName", "fieldType"));
127+
}
128+
}
123129
}
124130
```
125131

132+
The options class must be registered in the [Dependency Injection](https://our.umbraco.com/documentation/reference/using-ioc/) container to apply:
133+
134+
```
135+
builder.Services.ConfigureOptions<ConfigureIndexOptions>();
136+
```
137+
126138
#### Core fields
127139

128140
Umbraco's "path" field is automatically indexed as a list and so a content item with the path `-1,1050,1100` can be queried like this:
@@ -172,17 +184,26 @@ Each property will be created as a field in the index, including any nested prop
172184

173185
It is possible to index a subset of a JSON object's properties by supplying a path in (https://www.newtonsoft.com/json/help/html/QueryJsonSelectTokenJsonPath.htm)[JSON Path format].
174186

175-
Register a new `ValueTypeFactory` in `IExamineManager` implementing the `json` type, and define the path as a parameter, before assigning it to a field:
187+
Register a new `ValueTypeFactory` in the index implementing the `json` type, and define the path as a parameter, before assigning it to a field:
176188

177189
```
178-
if (examineManager.TryGetIndex("ExternalIndex", out IIndex index))
190+
public class ConfigureIndexOptions : IConfigureNamedOptions<LuceneDirectoryIndexOptions>
179191
{
180-
index.FieldValueTypeCollection.ValueTypeFactories.AddOrUpdate("position", new DelegateFieldValueTypeFactory(x =>
192+
public void Configure(string name, LuceneDirectoryIndexOptions options)
181193
{
182-
new JsonValueType(x, "$[*].position")
183-
}));
184-
185-
index.FieldDefinitionCollection.AddOrUpdate(new FieldDefinition("locations", "position"));
194+
if (name == "ExternalIndex")
195+
{
196+
options.IndexValueTypesFactory = new Dictionary<string, IFieldValueTypeFactory>(options.IndexValueTypesFactory)
197+
{
198+
["position"] = new DelegateFieldValueTypeFactory(fieldName =>
199+
{
200+
return new JsonValueType(fieldName, "$[*].position");
201+
};
202+
};
203+
204+
options.FieldDefinitions.AddOrUpdate(new FieldDefinition("locations", "position"));
205+
}
206+
}
186207
}
187208
```
188209

@@ -193,17 +214,30 @@ There are advanced cases where indexing a value as multiple field types might be
193214
The `MultipleValueTypeFactory` assigns a chain of field types to a field and applies them in sequence:
194215

195216
```
196-
if (examineManager.TryGetIndex("ExternalIndex", out IIndex index))
217+
public class ConfigureIndexOptions : IConfigureNamedOptions<LuceneDirectoryIndexOptions>
197218
{
198-
index.FieldValueTypeCollection.ValueTypeFactories.AddOrUpdate("locationData", new MultipleValueTypeFactory(x =>
199-
new IIndexFieldValueType[]
219+
public void Configure(string name, LuceneDirectoryIndexOptions options)
220+
{
221+
if (name == "ExternalIndex")
200222
{
201-
new JsonValueType(x, "$[*].city"),
202-
new JsonValueType("position", "$[*].position")
223+
options.IndexValueTypesFactory = new Dictionary<string, IFieldValueTypeFactory>(options.IndexValueTypesFactory)
224+
{
225+
["locationData"] = new DelegateFieldValueTypeFactory(fieldName =>
226+
{
227+
return new MultipleValueTypeFactory(
228+
fieldName,
229+
new IIndexFieldValueType[]
230+
{
231+
new JsonValueType(x, "$[*].city"),
232+
new JsonValueType("position", "$[*].position")
233+
}
234+
);
235+
};
236+
};
237+
238+
options.FieldDefinitions.AddOrUpdate(new FieldDefinition("locations", "locationData"));
203239
}
204-
));
205-
206-
index.FieldDefinitionCollection.AddOrUpdate(new FieldDefinition("locations", "locationData"));
240+
}
207241
}
208242
```
209243

0 commit comments

Comments
 (0)