Skip to content

Commit 5b0f771

Browse files
committedJan 5, 2020
config option to globally set the default for MaxResults (rather on a per request basis)
1 parent 16da1c1 commit 5b0f771

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed
 

‎README.md

+5
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ public static class LookConfiguration
118118
/// Setting it to LookFieldsOnly reduces the number of Lucene fields returned to the min required to inflate a LookMatch object.
119119
/// </summary>
120120
public static RequestFields RequestFields { set; }
121+
122+
/// <summary>
123+
/// (Optional) Specify the max number of results to return (defaults to 5000)
124+
/// </summary>
125+
public static int MaxResults { set { LookService.SetMaxResults(value); } }
121126
}
122127
```
123128

‎src/Our.Umbraco.Look/LookConfiguration.cs

+5
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,10 @@ public static class LookConfiguration
7070
/// Setting it to LookFieldsOnly reduces the number of Lucene fields returned to the min required to inflate a LookMatch object.
7171
/// </summary>
7272
public static RequestFields RequestFields { set { LookService.SetRequestFields(value); } }
73+
74+
/// <summary>
75+
/// (Optional) Specify the max number of results to return (defaults to 5000)
76+
/// </summary>
77+
public static int MaxResults { set { LookService.SetMaxResults(value); } }
7378
}
7479
}

‎src/Our.Umbraco.Look/Our.Umbraco.Look.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@
319319
<Compile Include="Services\LookService_ParseRawQuery.cs" />
320320
<Compile Include="Services\LookService_SetAfterIndexing.cs" />
321321
<Compile Include="Services\LookService_SetBeforeIndexing.cs" />
322+
<Compile Include="Services\LookService_SetMaxResults.cs" />
322323
<Compile Include="SortOn.cs" />
323324
<Compile Include="LookTag.cs" />
324325
<Compile Include="TagFacetQuery.cs" />

‎src/Our.Umbraco.Look/Services/LookService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ internal partial class LookService
9090
/// <summary>
9191
/// max number of results to request for a lucene query
9292
/// </summary>
93-
private int _maxResults => 5000;
93+
private int _maxResults = 5000;
9494

9595
/// <summary>
9696
/// Supplied by the initialization event (for re-use by the LookMatch)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace Our.Umbraco.Look.Services
2+
{
3+
internal partial class LookService
4+
{
5+
/// <summary>
6+
/// Set the default MaxResults value (defaults to 5000 if not specified)
7+
/// </summary>
8+
/// <param name="maxResults"></param>
9+
internal static void SetMaxResults(int maxResults)
10+
{
11+
if (maxResults > 0) // ensure it's a valid value
12+
{
13+
LookService.Instance._maxResults = maxResults;
14+
}
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)