Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jim Zador 5 posts 75 karma points
    Mar 06, 2019 @ 15:08
    Jim Zador
    0

    Indexing Files with Examine in an external directory

    I have a large directory of files (mostly PDFs) that I need indexed that sits outside of the media directory. Is there any way to do this? I'm using Cogworks.ExamineFileIndexer to index items in the Media folder, but the issue I have with keeping the files in the media directory through Umbraco is that every time the file is updated, it changes the URL, making management of the documents extremely difficult. So it seems creating a ExamineIndex of these files would be more practical.

    Has anyone else done this? Thank you!

  • Yakov Lebski 539 posts 2101 karma points
    Mar 10, 2019 @ 17:15
    Yakov Lebski
    0

    The simple way is to create custom Dataservice that inherits from ISimpleDataService

    something like this

    I found full example - https://github.com/kgiszewski/LearnUmbraco7/blob/master/Chapter%2009%20-%20Searching%20with%20Examine/04%20-%20Custom%20Data%20Sources.md

    public class BookshelfExamineDataService : ISimpleDataService
    {
        public IEnumerable<SimpleDataSet> GetAllData(string indexType)
        {
            var data = new List<SimpleDataSet>();
    
            LogHelper.Info<BookshelfExamineDataService>("Building index...");
    
            //this only adds one item to the index, but create a loop and go to town
            data.Add(new SimpleDataSet()
            {
                NodeDefinition = new IndexedNode()
                {
                    NodeId = 1, //a unique identifier
                    Type = "Bookshelf" //this should match the `type` in the ~/config/ExamineSettings.config
                },
                RowData = new Dictionary<string, string>()
                {
                    //this is a simple dictionary based on the ~/config/ExamineIndex.config file
                    //you can customize this however you want but the config should match this dictionary
                    {"book", "A Book"},
                    {"path", "/path/to/book"},
                    {"title", "All about that bass"},
                    {"text", "The entire page text if you wish."},
                    {"url", "/url/to/page"}
                }
            });
    
            return data;
        }
    }
    
  • Jim Zador 5 posts 75 karma points
    Mar 11, 2019 @ 14:04
    Jim Zador
    0

    Thank you! I'm going to try this out and report back! Thanks again!

Please Sign in or register to post replies

Write your reply to:

Draft