Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm programatically trying to use the Search Apis to find some documents.

In order to customize the process, I'm selecting some basic properties :

var query = new KeywordQuery(site)
{
    QueryText = queryText,
    ResultTypes = ResultType.RelevantResults
};

query.SelectProperties.Add("Title");
query.SelectProperties.Add("Language");

...

var result = query.Execute();

This is working fine.

Now I want to select the internal values of a taxonomy field. Let's say I have a field named AccessLevel, bound to a term set containing some values.

After a crawl, SharePoint has detected two crawled properties : AccessLevel (property containing the label) and ows_taxId_AccessLevel (property containing the lookup value of the taxonomy field, #label|termguid). A mapped property has also been created owstaxIdAccessLevel automatically.

I set up the crawled properties to be included in the index, I even start the full crawl, but if I add this code :

query.SelectProperties.Add("owstaxIdAccessLevel");

I got the following exception :

Microsoft.Office.Server.Search.Query.InvalidPropertyException was unhandled by user code
  Message=Property doesn't exist or is used in a manner inconsistent with schema settings.
  Source=Microsoft.Office.Server.Search
  Property=The creator of this fault did not specify a Reason.
  StackTrace:
       at Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.ThrowBackwardCompatibleException(FaultException`1 ex)
       at Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.DoSpLoadBalancedUriWsOp[T](WebServiceBackedOperation`1 webServiceCall, Int32 timeoutInMilliseconds, Int32 wcfTimeoutInMilliseconds, String operationName)
       at Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.DoWebServiceBackedOperation[T](String operationName, Int32 timeoutInMilliseconds, Int32 wcfTimeoutInMilliseconds, WebServiceBackedOperation`1 webServiceCall)
       at Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.Execute(QueryProperties properties)
       at Microsoft.Office.Server.Search.Query.Query.Execute()
       atMyProject.MyModuleConnectorSearchWrapper.SearchDocuments(SPSite site, String queryText, IEnumerable`1 retrieveProperties, Boolean includeDefaultProperties, Int32 startRow, Int32 rowsPerPage, Int32& estimatedRowCount)
       atMyProject.WebService.MyModuleConnector.<>c__DisplayClass3.<Search>b__1()
       at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2()
       at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
  InnerException: System.ServiceModel.FaultException<Microsoft.Office.Server.Search.Administration.SearchServiceApplicationFault>
       Message=The creator of this fault did not specify a Reason.
       Source=mscorlib
       Action=http://tempuri.org/ISearchQueryServiceApplication/ExecuteSearchServiceApplicationFaultFault
       StackTrace:
         Server stack trace: 
            at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
            at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
            at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
            at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
         Exception rethrown at [0]: 
            at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
            at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
            at Microsoft.Office.Server.Search.Query.ISearchQueryServiceApplication.Execute(QueryProperties properties)
            at Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.<>c__DisplayClass4.<Execute>b__3(ISearchServiceApplication serviceApplication)
            at Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.DoSpLoadBalancedUriWsOp[T](WebServiceBackedOperation`1 webServiceCall, Int32 timeoutInMilliseconds, Int32 wcfTimeoutInMilliseconds, String operationName)
       InnerException: 

Is there any restriction on querying Taxonomy fields? What can I do to make my search works?

share|improve this question
    
I haven't found out exactly why this is, but I have done it successfully on one system, the same deployment on another produces your error. I read if you map it to the other field (The plaintext version of the field) of the managed metadata field it works. Didn't fix it for me though. –  Hugh Wood Nov 22 '12 at 11:17
add comment

1 Answer

An interesting discovery: if I run this small PS script :

$prop = Get-SPEnterpriseSearchMetadataManagedProperty -
earchApplication $ssa -Identity owstaxIdAccessLevel
$prop.Retrievable

It's returning :

False

Then I can update this property:

$prop.Retrievable = $true
$prop.Update()

After a full crawl, I'm now able to query my taxonomy field.

However, I'm don't measure now the potential side effects of this change

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.