Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ISearchableTree in v8 #3805

Closed
Shazwazza opened this issue Nov 30, 2018 · 2 comments
Closed

Fix ISearchableTree in v8 #3805

Shazwazza opened this issue Nov 30, 2018 · 2 comments

Comments

@Shazwazza
Copy link
Contributor

Shazwazza commented Nov 30, 2018

Ensure ISearchableTree is working and used in the back office

(will be part of PR #3852)

child of #3530

@Shazwazza
Copy link
Contributor Author

Confirmed this now works. An example of how this would work (this is prior to the DI branch being merged in, so this syntax may change)

In a Compose method of an IUmbracoComponent you could do this to replace the content search:

var searchableTreeCollectionBuilder = composition.Container.GetInstance<SearchableTreeCollectionBuilder>();
searchableTreeCollectionBuilder.Exclude<ContentTreeController>();
searchableTreeCollectionBuilder.Add<MySearchableTree>();

and then include your own class, for example:

        private class MySearchableTree : ISearchableTree
        {
            public string TreeAlias => Constants.Trees.Content;

            public IEnumerable<SearchResultEntity> Search(string query, int pageSize, long pageIndex, out long totalFound, string searchFrom = null)
            {
                totalFound = 1;
                return new[]
                {
                    new SearchResultEntity
                    {
                        Id = 123,
                        Name = "Hello world",
                        Key = Guid.NewGuid(),
                        Score = 1,
                    }
                };
            }
        }

@Shazwazza
Copy link
Contributor Author

See #3534 for other testing notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants