You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_Looking for Search Extensions for **Umbraco 9**? Check the [v9/dev](https://github.com/callumbwhyte/umbraco-search-extensions/tree/v9/dev) branch._
8
9
9
10
## Getting started
10
11
@@ -75,17 +76,17 @@ The `SearchHelper` class contains logic for commonly performed actions when sear
75
76
The `Get<T>` method gets all results for a query cast to a given type, including `IPublishedContent`.
76
77
77
78
```
78
-
var query = _searcher.CreatePublishedQuery();
79
+
var query = searcher.CreatePublishedQuery();
79
80
80
-
var results = _searchHelper.Get<T>(query, out int totalResults);
81
+
var results = searchHelper.Get<T>(query, out int totalResults);
81
82
```
82
83
83
84
The `Page<T>` method efficiently gets a given number of items *(`perPage`)* at a specific position *(`page`)* in the results for a query An optional type constraint can be added to also return paged results cast to `IPublishedContent`.
84
85
85
86
```
86
-
var query = _searcher.CreatePublishedQuery();
87
+
var query = searcher.CreatePublishedQuery();
87
88
88
-
var results = _searchHelper.Page<T>(query, int page, int perPage, out int totalResults);
89
+
var results = searchHelper.Page<T>(query, int page, int perPage, out int totalResults);
89
90
```
90
91
91
92
All helper methods provide the total number of results found as an `out` parameter.
@@ -116,12 +117,14 @@ Search Extensions introduces several new field types into Examine – `json`, `l
116
117
Defining which fields in the index use which types is done through the `IExamineManager`:
117
118
118
119
```
119
-
if (_examineManager.TryGetIndex("ExternalIndex", out IIndex index))
120
+
if (examineManager.TryGetIndex("ExternalIndex", out IIndex index))
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:
126
129
127
130
```
@@ -172,7 +175,7 @@ It is possible to index a subset of a JSON object's properties by supplying a pa
172
175
Register a new `ValueTypeFactory` in `IExamineManager` implementing the `json` type, and define the path as a parameter, before assigning it to a field:
173
176
174
177
```
175
-
if (_examineManager.TryGetIndex("ExternalIndex", out IIndex index))
178
+
if (examineManager.TryGetIndex("ExternalIndex", out IIndex index))
176
179
{
177
180
index.FieldValueTypeCollection.ValueTypeFactories.AddOrUpdate("position", new DelegateFieldValueTypeFactory(x =>
178
181
{
@@ -190,7 +193,7 @@ There are advanced cases where indexing a value as multiple field types might be
190
193
The `MultipleValueTypeFactory` assigns a chain of field types to a field and applies them in sequence:
191
194
192
195
```
193
-
if (_examineManager.TryGetIndex("ExternalIndex", out IIndex index))
196
+
if (examineManager.TryGetIndex("ExternalIndex", out IIndex index))
194
197
{
195
198
index.FieldValueTypeCollection.ValueTypeFactories.AddOrUpdate("locationData", new MultipleValueTypeFactory(x =>
196
199
new IIndexFieldValueType[]
@@ -224,6 +227,6 @@ The package logo uses the [Magnifying Glass](https://thenounproject.com/term/sea
0 commit comments