My Session in RSUG Jan 2012

On 2/2/2012 it was my third session in RSUG with my friends Jerry , Megren and AhmadAbouAbdo. We all talked about SharePoint 2010 Search. My session was focus on custom development search.

 

First, I listed why we need custom development and what are the reasons:

  • Modify the end user experience
  • Create new visual elements (chart , maps)
  • Search for related items
  • Querying external data sources (Exchange Emails)
  • Adding extra actions to results
  • Querying Multiple Federated Locations at same web part
  • Bring results to another locations
and then I talked, what the ways to query the search in custom development which are:
  • Search Webservice
  • Object Model

Web Service

first, build the query XML as below

StringBuilder queryXml=new StringBuilder();
queryXml.Append("<QueryPacket xmlns=\"urn:Microsoft.Search.Query\" Revision=\"1000\">");
 queryXml.Append("<Query domain=\"QDomain\">");
 queryXml.Append("<SupportedFormats>");
 queryXml.Append("</SupportedFormats>");
 queryXml.Append("<Range>");
 queryXml.Append("<Count>50</Count>");
 queryXml.Append("</Range>");
 queryXml.Append("<Context>");
 queryXml.Append("<QueryText language=\"en-US\" type=\"FQL\">");
 queryXml.Append(txtBoxQuery.Text);
 queryXml.Append("</QueryText>");
 queryXml.Append("</Context>");
 queryXml.Append("</Query>");
 queryXml.Append("</QueryPacket>");
return queryXml.ToString();

then, call the webservice as below after adding the web service reference http://<yoursite>/_vti_bin/search.asmx

 SearchWS.QueryService queryService = new SearchWS.QueryService();
 queryService.Credentials = System.Net.CredentialCache.DefaultCredentials;
 
 System.Data.DataSet queryResults = queryService.QueryEx(GetXMLString());
 
 resultsGrid.DataSource = queryResults.Tables[0];

Object Model

but you need to add the following assemblies:

  • Microsoft.Office.Server
  • Microsoft.Office.Server.Search
KeywordQuery query = new KeywordQuery("http://win8r2:2000/");
 query.ResultsProvider = Microsoft.Office.Server.Search.Query.SearchProvider.Default;
query.QueryText = txtBoxQuery.Text;
 query.ResultTypes = ResultType.VisualBestBetsResults | ResultType.RelevantResults;
 ResultTableCollection searchResults = query.Execute();
 
 
 if (searchResults.Exists(ResultType.RelevantResults))
 {
 ResultTable searchResult = searchResults[ResultType.VisualBestBetsResults];
 
 
 DataTable result = new DataTable();
 result.TableName = "Result";
 result.Load(searchResult, LoadOption.OverwriteChanges);
resultsGrid.DataSource = result;
 }

and this is the link http://rsugjan12.eventbrite.com/

Advertisements

Why my site column not appearing in Crawled Properties?

I was created a site column and I need this column to appear in the search results or filter the restuls based on this column. To do this, the column must appear in crawled properties in the searh admin page first. But the column not appear there!!!!!

Solution

You need to to do incremental or full crawl. 😉

Refiners does not work with SharePoint 2010 Enterprise Search

I am testing the serach.asmx web service for querying the search from SharePoint 2010 with Refiners, but I noticed that my refiners in the query xml does not effect the resutls. after my serach , I found that the refiners work only with FAST Search Server 2010 for SharePoint according to this MSDN article.

<QueryPacket xmlns=\”urn:Microsoft.Search.Query\” Revision=\”1000\”>
<Query domain=\”QDomain\”>
<SupportedFormats>
<Format>
urn:Microsoft.Search.Response.Document.Document
</Format>
</SupportedFormats>
<Range>
<Count>50</Count>
</Range>
<Context>
<QueryText language=\”en-US\” type=\”FQL\”>
queryXml.Append(txtBoxQuery.Text);
</QueryText>
</Context>
<IncludeRefinementResults>
<Refiners>
<Refiner>author</Refiner>
<Refiner>write</Refiner>
<Refiner>sitename</Refiner>
<Refiner>format</Refiner>
<Refiner>owsmetadatafacetinfo</Refiner>
</Refiners>
</IncludeRefinementResults>
</Query>
</QueryPacket>