1: <%@ WebHandler Language="C#" Class="GenericHandler1" %>
2: <%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
3: <%@ Assembly Name="Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
4: <%@ Assembly Name="Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
5:
6: using System;
7: using System.Web;
8: using System.Data;
9: using Microsoft.SharePoint;
10: using Microsoft.Office.Server.Search.Query;
11:
12: public class GenericHandler1 : IHttpHandler { 13:
14: public void ProcessRequest (HttpContext context) { 15: context.Response.ContentType = "text/plain";
16:
17: string prefixText = context.Request["q"];
18: using (SPSite siteCollection = SPContext.Current.Site)
19: { 20: // create a new FullTextSqlQuery class
21: FullTextSqlQuery query = new FullTextSqlQuery(siteCollection);
22: query.QueryText = string.Format("SELECT Title FROM SCOPE() WHERE FREETEXT(defaultproperties, '{0}*') AND \"Scope\"='People' ", prefixText); 23: query.ResultTypes = ResultType.RelevantResults;
24: query.RowLimit = 10;
25:
26: // execute the query
27: ResultTableCollection queryResults = query.Execute();
28: ResultTable queryResultsTable = queryResults[ResultType.RelevantResults];
29:
30:
31: while(queryResultsTable.Read()){ 32: context.Response.Write(queryResultsTable.GetString(0) + Environment.NewLine);
33: }
34: }
35:
36: }
37:
38: public bool IsReusable { 39: get { 40: return false;
41: }
42: }
43:
44: }