Data Types of Managed Properties in Search Results

Posted Tuesday, December 9, 2008 4:17 PM by CoreyRoth

The other day, I was trying to work some XSLT magic with my CoreResultsWebPart.  What I was trying to do is pass an integer value in a search query (that went against a BDC application definition) in a link to a page.  This should be a simple task, but when I added the field to my template, it displayed the value of System.Int64[] instead of the value of the integer.  This obviously wouldn't work with the page on the other side of the link that is expecting that integer value.

I first went back to my BDC application definition and confirmed that the field in the TypeDescriptor element was in fact set to System.Int32.  I then decided to issue my query with some code going against the web service.  I discovered that other builtin fields were returning Int64 as the type, but mine was returning the type as Object (I am sure there is a reason it uses Int64 versus Int32, but I don't know).   This led me back to the Managed Property itself.  I took a look and saw that I had two crawled properties (from two different BDC application definitions) mapped to it.  On a hunch, I removed one of them and recrawled my content source.  I ran my query again and to my surprise it was now returning the field as an Int64 as intended.

So the lesson, I have learned here is that Enterprise Search uses an Object type when you are mapping multiple crawled properties to one managed property.  I am not really sure why this is, but I assume it thinks that it might receive a different type from one of the crawled properties (even though it wouldn't let you map it).  Now my only issue is that if I want to have multiple crawled properties map to a single managed property in this case.  It may also be possible to somehow cast the object back into an integer and get the actual value, but my XSL skills aren't that good.  If you know how to do it, please let me know.

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required)