Skip to content

Commit

Permalink
Support fallback search index (#835)
Browse files Browse the repository at this point in the history
  • Loading branch information
neexite authored Oct 10, 2023
1 parent 09cc244 commit 7583a86
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions Composite/Search/DocumentSources/CmsPageDocumentSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@

namespace Composite.Search.DocumentSources
{
internal class CmsPageDocumentSource : ISearchDocumentSource
public class CmsPageDocumentSource : ISearchDocumentSource
{
const string LogTitle = nameof(CmsPageDocumentSource);

private readonly List<IDocumentSourceListener> _listeners = new List<IDocumentSourceListener>();
protected List<IDocumentSourceListener> _listeners = new List<IDocumentSourceListener>();
private readonly DataChangesIndexNotifier _changesIndexNotifier;
private readonly Lazy<IReadOnlyCollection<DocumentField>> _customFields;
private readonly IEnumerable<ISearchDocumentBuilderExtension> _docBuilderExtensions;
protected Lazy<IReadOnlyCollection<DocumentField>> _customFields;
protected IEnumerable<ISearchDocumentBuilderExtension> _docBuilderExtensions;

protected CmsPageDocumentSource()
{
}

public CmsPageDocumentSource(IEnumerable<ISearchDocumentBuilderExtension> extensions)
{
Expand Down Expand Up @@ -55,14 +59,14 @@ public CmsPageDocumentSource(IEnumerable<ISearchDocumentBuilderExtension> extens
_changesIndexNotifier.Start();
}

public string Name => typeof (IPage).FullName;
public virtual string Name => typeof (IPage).FullName;

public void Subscribe(IDocumentSourceListener sourceListener)
public virtual void Subscribe(IDocumentSourceListener sourceListener)
{
_listeners.Add(sourceListener);
}

public IEnumerable<DocumentWithContinuationToken> GetSearchDocuments(CultureInfo culture, string continuationToken = null)
public virtual IEnumerable<DocumentWithContinuationToken> GetSearchDocuments(CultureInfo culture, string continuationToken = null)
{
ICollection<IPage> unpublishedPages;
IDictionary<Guid, Guid> parentPageIDs;
Expand Down Expand Up @@ -145,7 +149,7 @@ public IEnumerable<DocumentWithContinuationToken> GetSearchDocuments(CultureInfo
public IReadOnlyCollection<DocumentField> CustomFields => _customFields.Value;


private SearchDocument FromPage(IPage page, EntityToken entityToken, Dictionary<Tuple<Guid, Guid>, List<IData>> allMetaData)
protected virtual SearchDocument FromPage(IPage page, EntityToken entityToken, Dictionary<Tuple<Guid, Guid>, List<IData>> allMetaData)
{
string label = page.MenuTitle;
if (string.IsNullOrWhiteSpace(label))
Expand Down Expand Up @@ -216,7 +220,7 @@ private EntityToken GetAdministratedEntityToken(IPage page)
}
}

private string GetDocumentId(IPage page)
protected virtual string GetDocumentId(IPage page)
{
bool isUnpublished = page.DataSourceId.PublicationScope == PublicationScope.Unpublished;

Expand Down Expand Up @@ -329,7 +333,7 @@ private bool AllAncestorPagesArePublished(Guid pageId, CultureInfo locale)
return false;
}

private bool PageShouldBeIndexed(IData data)
protected bool PageShouldBeIndexed(IData data)
{
if (!(data is IPage page))
{
Expand Down

0 comments on commit 7583a86

Please sign in to comment.