Test

Indexing Service - Blank or Null Characterization Field

Monday, March 21, 2011

Blank or Null Characterization Field When Pulling From Indexing Service

This one drove me ape shit for about two hours...  Hope this helps someone else.

I'm using Indexing Service on Windows 7.  One thing to note before I continue, is that MS has all but given up on Indexing Service.  For good reason: it sucks.  So even if you select a website from the Tracking tab in the catalog's properties it will not play with IIS and you will not get a vpath property back.  Took me a while to figure out why vpath was coming back blank.  That's why...or so I've read.

So why isn't Characterization showing up?  I guess you have to turn it on.  Here's how I did it:

  1. Go to your Indexing Service management console.  You should likely know where this is if you've made it this far. ;)
  2. Right-click on the catalog you want to modify and select properties.
  3. Click on the Generation tab and make sure Generate abstracts is checked.  You can set a maximum size in characters just below.  This is how big your summary/abstract will be.  I set mine to 300 for good measure.

    Characterization - 1
  4. Expand the catalog to reveal the folders below.  Click on Properties to list the available properties for the catalog.
  5. Find Characterization by using the Friendly Name column.  Right-click and select Properties.
  6. Check the Cached box and leave all the settings as they are.  I assumed Size was the amount of space set aside for this property in the cache, and made a further assumption that it was in bytes so I set it to 300.  I could be wrong on this though, but so far so good.

    Characterization - 2
  7. Click OK.  You'll get a warning that the change will not take effect until Indexing Service is restarted.  Just OK out of that and restart the service.  For good measure, I did a full rescan of the directory I have my catalog pointed at.

That's it.  Now I get a summary.  It's kinda lame as it cuts off mid word, so you might want to write a function that grabs the text from index 0 to the last index of " " (a space) and then append ... to the end or something fancy.  Ah hell, here's the code in C#:

  • protected string GetTruncatedSummary(object summary) {
    • string result = string.Empty;
    • if (summary != null) {
      • result = summary.ToString();
      • result = result.Substring(0, result.LastIndexOf(" ")) + "...";
    • }
    • return string.Empty;
  • }

So my code may need some refactoring.  It was a bonus anyway. ;)  I call this in my DataGrid with the following:

<%# GetTruncatedSummary(DataBinder.Eval(Container.DataItem, "Characterization")) %>

I'm using ASP.NET 1.1 in the above example (I know...blech...) otherwise you could probably just use

<%# GetTruncatedSummary(Eval("Characterization")) %>

That's it!  Hope this helps someone.