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.
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 :)
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;
}
}
}
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.
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).
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
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.
So you want to do it programmatically?
You can get an instance of your provider like so:
You can then access the Lucene indexer properties by casting it, like so:
You can do the same with a searcher:
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 :)
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:
Adriano,
You can do it using lucene.net so
IndexReader reader; directory = FSDirectory.Open(new DirectoryInfo(indexPath)); reader = IndexReader.Open(directory, true); var noOfDocs= reader.MaxDoc()
Regards
Ismail
Thank you...and for optimize the index? :-)
is working on a reply...