Copied to clipboard

Flag this post as spam?

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


  • Adriano Fabri 459 posts 1602 karma points
    Jun 22, 2017 @ 10:21
    Adriano Fabri
    0

    Info about Examine indexer

    What is the best way to get examine informations?

    I need to retrieve some informations about my cutom Indexer:

    Total number of Documents

    Total number of Fields (and what)

    If it is optimized

    ... etc.

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Jun 22, 2017 @ 11:30
    Dan Diplo
    0

    You should be able to get this from the Examine Management dashboard in the Developer section of Umbraco.

    Go to Developer section, select the Examine Management tab on right. Select your index, expand it, then you can expand the various things like fields etc.

    There's also a desktop application called Luke that is great for viewing examine (lucene) data. See https://code.google.com/archive/p/luke/ (but it's JAVA - boo!) or https://luke.codeplex.com/ (for .NET version).

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Jun 22, 2017 @ 11:40
    Ismail Mayat
    0

    Heads up,

    There is also ExamineInspector package coming very soon its v7 upgrade of the older one I wrote https://our.umbraco.org/projects/backoffice-extensions/examine-inspector/ so its like a cut down luke

  • Adriano Fabri 459 posts 1602 karma points
    Jun 22, 2017 @ 11:49
    Adriano Fabri
    0

    Thanks to all...but I'm creating a custom plugin task that auto rebuild my custom Index in the night.

    Everytime rebuild start, I save a Trace Log entry with the result message.

    Now I would to add another trace log entry with the principal details of the index as described in my first post, to have a little summary.

    I tried to use ExamineManager, but I don't find methods to retrieve index details.

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Jun 22, 2017 @ 12:26
    Dan Diplo
    0

    So you want to do it programmatically?

    You can get an instance of your provider like so:

    var examineProvider = Examine.ExamineManager.Instance.IndexProviderCollection["providerName"];
    

    You can then access the Lucene indexer properties by casting it, like so:

    var indexer = examineProvider as Examine.LuceneEngine.Providers.LuceneIndexer;
    

    You can do the same with a searcher:

    var examineSearcher = Examine.ExamineManager.Instance.SearchProviderCollection["providerName"];
    
    var searcher = examineSearcher as Examine.LuceneEngine.Providers.LuceneSearcher;
    

    That will get you access to some data, though not sure if it's what you are after.

    Hopefully Ismail can help more, as he's Mr. Examine :)

  • Adriano Fabri 459 posts 1602 karma points
    Jun 22, 2017 @ 12:53
    Adriano Fabri
    0

    I have already tried this but I can not, for example, get the total number of indexed documents. Can you or Ismail tell me an example how can I get this number?

    This is my current examine task plugin code:

    // EXAMINE
    using Examine;
    
    // SYSTEM
    using System;
    using System.Web.Configuration;
    using Umbraco.Web;
    
    // UMBRACO
    using Umbraco.Web.Mvc;
    using Umbraco.Web.Search;
    using Umbraco.Web.WebApi;
    using Umbraco.Web.WebServices;
    
    namespace AF.UmbTasks.Plugins
    {
        /// <summary>
        /// 
        /// </summary>
        [PluginController("AFTasks")]
        public class ExamineController : UmbracoApiController
        {
            [System.Web.Http.HttpGet]
            public string ExamineIndexRebuild(string code)
            {
                string rebuildResultMessage = string.Empty;
    
                try
                {
                    //validate the querystring
                    if (!String.IsNullOrEmpty(code))
                    {
                        ExamineManager.Instance.IndexProviderCollection[code].RebuildIndex();
    
                        rebuildResultMessage = "AFTask: The Examine Index successfully rebuilded (" + code + ")";
                        Logger.Info(typeof(ExamineController), rebuildResultMessage);
                    }
                    else
                    {
                        rebuildResultMessage = "AFTask: The Examine Index has not been rebuilt! The Indexer name is missing";
                        Logger.Error(typeof(ExamineController), rebuildResultMessage, new Exception("Empty or NULL Indexer Name"));
                    }
                }
                catch (Exception ex)
                {
                    rebuildResultMessage = "AFTask: The Examine Index has not been rebuilt! The \"" + code + "\" indexer does not exist";
                    Logger.Error(typeof(ExamineController), rebuildResultMessage, ex);
                }
    
                return rebuildResultMessage;
            }
        }
    }
    
  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Jun 22, 2017 @ 15:43
    Ismail Mayat
    100

    Adriano,

    You can do it using lucene.net so

    FSDirectory directory;
    

    IndexReader reader; directory = FSDirectory.Open(new DirectoryInfo(indexPath)); reader = IndexReader.Open(directory, true); var noOfDocs= reader.MaxDoc()

    Regards

    Ismail

  • Adriano Fabri 459 posts 1602 karma points
    Jun 23, 2017 @ 11:12
    Adriano Fabri
    0

    Thank you...and for optimize the index? :-)

Please Sign in or register to post replies

Write your reply to:

Draft