none
KeywordQuery Property doesn't exist or is used in a manner inconsistent with schema settings. RRS feed

  • Question

  • hi all,

    I want to get the contenttype which crawled by sharepoint using KeywordQuery,but it says:"Property doesn't exist or is used in a manner inconsistent with schema settings." when myQuery.SelectProperties.Add("contenttype");

    In content source,it look like this:

    in managed property,it looks like this:

    using (SPSite siteCollection = new SPSite(siteCollectionConfig))
                {
    
                    DataTable queryDataTable = new DataTable();
                    try
                    {
                        SearchQueryAndSiteSettingsServiceProxy settingsProxy = siteCollection.WebApplication.Farm.ServiceProxies.GetValue<SearchQueryAndSiteSettingsServiceProxy>();
                        SearchServiceApplicationProxy proxy = settingsProxy.ApplicationProxies.GetValue<SearchServiceApplicationProxy>(ssa);
    
                        KeywordQuery myQuery = new KeywordQuery(proxy);
    
    
                        myQuery.QueryText = strQuery;
                        //myQuery.ResultsProvider = SearchProvider.FASTSearch;
                        myQuery.ResultsProvider = provider;
                        myQuery.RowLimit = 9999;
                        myQuery.ResultTypes = ResultType.RelevantResults | ResultType.RefinementResults;
                        
    
                        if (provider == SearchProvider.SharepointSearch)
                        {
                            myQuery.SelectProperties.Add("title");//this is ok
    myQuery.SelectProperties.Add("contenttype");//this throw a error
                        }
    
                        ResultTableCollection queryResults = myQuery.Execute();
    
                        ResultTable queryResultsTable = queryResults[rt];
                        queryDataTable.Load(queryResultsTable, LoadOption.OverwriteChanges);
    
                    }
                    catch { }
    
                    return queryDataTable;
    
                }

    Please help me ,thank you

    Fiyoung


    In God We Trust

    Friday, September 28, 2012 7:49 AM

All replies

  • Did you get an answer for this problem please ?
    Wednesday, April 19, 2017 10:41 AM
  • Hi,

       This will help you.

    the Keywordquery to search on ContentType is contenttype:"Excel". In this case, "contenttype" must be a managed property in your Search Settings, which must be mapped to your content type column. Default content type column in "ows_ContentType" under category SharePoint.

    Crawled Property: ows_ContentType

    Category: SharePoint

    Variant Type: 31
    Data Type: Text
    Multi-valued: No 

    Managed Property: Any friendly name you would like to use. eg "contenttype", "mycontenttype" etc

    Mapping: You need to added mapping of crawled property ows_ContentType to managed property of your choice

    Hope this helps you.

    -----------------------------------------------------------------------------------------------------

    Please mark as answer if this helps.

    Thursday, April 27, 2017 11:02 AM