views:

234

answers:

2

Does anybody know how I can map the "UniqueID" property to a managed property so I can display it in the advanced search results? This property is not visible when I try to create a new managed property using Metadata Property Mappings link in shared services administration.

Using the SiteData or Lists web service I can see the "ows_UniqueId" property, and using the object model I can access the SPListItem.UniqueID property - but I can't seem to find a way to map that to a crawled / managed property.

A: 

It should already be indexed. Have you tried using objectid? This is shown as mapping to SharePoint:objectid(Text). It looks the closest to what you're after.

Alex Angas
Thanks for the reply, alex.I tried with objectid, but found that it retrieves the "webid" that is returned by the webservice.I was just checking the database and found the "CompactURL" column in MSSCrawlURL table contains the value that i get in ows_uniqueid property returned by the webservice. But there is no such crawled property that i can map to the managed property. Any ideas??thanks and regards
deepa.s
@deepa.s It should be achievable but sorry I don't know how. I've never found the web services to be much good. Also, you probably already know but be careful querying the database: http://stackoverflow.com/questions/1437176/how-to-get-last-modified-time-of-a-document-in-sharepoint/1437591#1437591
Alex Angas
A: 

It is kind of painful, and probably unsupported but here is what you need to do to make the UniqueId a crawled property / mapped property such that it can be included in the advanced search results...

First, you need to internally change the UniqueId field on the list(s) you wish to search such that it is no longer hidden and can be indexed by the crawler. Here is some sample object model code:

// this is the identifier for UniqueId
Guid g = new Guid("4b7403de8d9443e89f0f137a3e298126");
// we will need these for reflection in a bit
BindingFlags bf = BindingFlags.NonPublic | BindingFlags.Instance;
using (SPSite s = new SPSite("http://SharePoint/")) {
  // grab the list that contains what you want indexed
  // and the UniqueId field from that list
  SPList l = s.RootWeb.Lists["Your Custom List/Library"];
  SPField f = l.Fields[g];
  // We need to call the private method SetFieldBoolValue
  // to allow us to change the Hidden property to false
  MethodInfo mi = f.GetType().GetMethod("SetFieldBoolValue", bf);
  mi.Invoke(f, new object[] { "CanToggleHidden", true });
  f.Hidden = false;
  f.Update();
}

Once that code has been run (and on all the lists/libraries you want covered), you need to perform a three steps in the Shared Services Search Administration:

  • Perform a full crawl.
  • After the full crawl finishes, navigate to the Crawled Property Categories (typically /ssp/admin/_layouts/schema.aspx?ConsoleView=crawledPropertiesView on your server) and verify that a property called ows_UniqueId exists. You then need to create a Managed Property called UniqueId that maps to ows_UniqueId.
  • Perform another full crawl.

Once the second full crawl has completed, you should have data populated in the index containing the UniqueId. You can expose it in the advanced search by modifying the Search Core Results:

  • Open the web part for editing
  • Expand the "Results Query Options"
  • Modify the XML for the Selected Columns to include a reference for UniqueId
  • Modify the XSL for the Data View Properties to include a statement to output the UniqueId
  • Click OK, and publish the page if necessary
Goyuix