KeywordQuery Error: Property doesn’t exist or is used in a manner inconsistent with schema setting

In the following code of a web part that was doing a custom KeywordQuery search, I received the error “Property doesn’t exist or is used in a manner inconsistent with schema settings.”  The Properties that I was adding to the KeywordQuery had not yet been mapped in the Search Service Application, Metadata Properties:

//Get associated search service application
SearchServiceApplicationProxy proxy = (SearchServiceApplicationProxy)SearchServiceApplicationProxy.GetProxy
                    (SPServiceContext.GetContext(SPContext.Current.Site));

                //Use Keyword Query
                Microsoft.Office.Server.Search.Query.KeywordQuery keywordQuery = new Microsoft.Office.Server.Search.Query.KeywordQuery(proxy);
                keywordQuery.ResultsProvider = Microsoft.Office.Server.Search.Query.SearchProvider.Default;

                //Return following properties          
                keywordQuery.SelectProperties.Add("ProjectCreator");
                keywordQuery.SelectProperties.Add("ProjectName");
                keywordQuery.SelectProperties.Add("ProjectDescription");
                keywordQuery.SelectProperties.Add("ProjectStage");
                keywordQuery.SelectProperties.Add("Path");
                keywordQuery.SelectProperties.Add("Title");
                keywordQuery.SelectProperties.Add("Id");
                keywordQuery.SelectProperties.Add("SiteName");

To map these properties, go to the Search Service Application –> Metadata Properties page in Central Administration –> Application Management.
Mapp_Crawled_Property_0

Select “New Managed Property”

Mapp_Crawled_Property1

Type the new Managed Property and add a mapping

Mapp_Crawled_Property

In my case, I am mapping to properties that were promoted from an InfoPath form.

Mapp_Crawled_Property3

Once the property is mapped, re-run an incremental or full crawl on your content source which contains the property

  1. Leave a comment

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: