forked from umbraco/Umbraco-CMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decouple Lucene from Content Delivery API (umbraco#15493)
* Decouples Lucene from the Content Delivery API * oops removes other refs
- Loading branch information
Showing
5 changed files
with
55 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/Umbraco.Cms.Api.Delivery/Services/QueryBuilders/ApiContentQueryFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Examine; | ||
using Examine.Lucene.Providers; | ||
using Examine.Lucene.Search; | ||
using Examine.Search; | ||
using Umbraco.Cms.Infrastructure.Examine; | ||
|
||
namespace Umbraco.Cms.Api.Delivery.Services.QueryBuilders | ||
{ | ||
internal sealed class ApiContentQueryFactory : IApiContentQueryFactory | ||
{ | ||
/// <inheritdoc/> | ||
public IQuery CreateApiContentQuery(IIndex index) | ||
{ | ||
// Needed for enabling leading wildcards searches | ||
BaseLuceneSearcher searcher = index.Searcher as BaseLuceneSearcher ?? throw new InvalidOperationException($"Index searcher must be of type {nameof(BaseLuceneSearcher)}."); | ||
|
||
IQuery query = searcher.CreateQuery( | ||
IndexTypes.Content, | ||
BooleanOperation.And, | ||
searcher.LuceneAnalyzer, | ||
new LuceneSearchOptions { AllowLeadingWildcard = true }); | ||
|
||
return query; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/Umbraco.Cms.Api.Delivery/Services/QueryBuilders/IApiContentQueryFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Examine; | ||
using Examine.Search; | ||
|
||
namespace Umbraco.Cms.Api.Delivery.Services.QueryBuilders | ||
{ | ||
/// <summary> | ||
/// Used to create an <see cref="IQuery"/> instance for content items for the content delivery api. | ||
/// </summary> | ||
public interface IApiContentQueryFactory | ||
{ | ||
/// <summary> | ||
/// Creates an <see cref="IQuery"/> for content items for the content delivery api. | ||
/// </summary> | ||
/// <param name="index">The <see cref="IIndex"/>.</param> | ||
/// <returns>An <see cref="IQuery"/> instance.</returns> | ||
IQuery CreateApiContentQuery(IIndex index); | ||
} | ||
} |