Wednesday, August 10, 2011

KeywordQuery and 'property' search + partial text Search

SharePoint 2010 provides filtering of your search based on properties. and you can search for partial text as well(just entering few initial character)

Create your Query like :
                QueryText = <property:queryText> OR title:<Your Search Keyword> OR fileextension:PDF


Sample Example :
                KeywordQuery query = new KeywordQuery(proxy);

                query.HiddenConstraints = "scope:\"<your Scope Name>\"";

                query.ResultsProvider = Microsoft.Office.Server.Search.Query.SearchProvider.Default;
                query.QueryText = "title:" + queryText;
                query.ResultTypes |= ResultType.RelevantResults;
                ResultTableCollection searchResults = query.Execute();

No comments:

Post a Comment