views:

66

answers:

2

How to use kyewordsearch query in c# to implement the Search object. What settings need through Central administration to enable kyewordsearch query ?

Also please send me Syntax for KeywordQuery.QueryText. means how to write query ?

+2  A: 

Take a look at http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/02/19/how-to-use-the-moss-enterprise-search-keywordquery-class.aspx

Dan Vallejo
I gone through this link. How to add Managed Properties. What is it exact ?
Lalit
+1  A: 

Lalit,

Have a look at this in msdn. You will all information you need there.

http://msdn.microsoft.com/en-us/library/ms544561%28office.12%29.aspx

Also, in the same page, have a look at which scenarios suit Keyword query(simple queries with keyword syntax, this will not required constructing a complete query but only keywords will suffice) and scenarios that suit FullText query( if you need complex queries to be executed which include query elements like Contains, Like, OrderBy etc which is not possible using Keyword query syntax).

As a simple example:

ServerContext context = ServerContext.GetContext(HttpContext.Current);

        using (KeywordQuery keywordQuery = new KeywordQuery(context))
        {
            keywordQuery.ResultTypes = ResultType.RelevantResults;
            keywordQuery.EnableStemming = true;
            keywordQuery.TrimDuplicates = true;
            keywordQuery.StartRow = 0;
            keywordQuery.SortList.Add(filterField, SortDirection.Ascending);

           keywordQuery.QueryText = string.Format(CultureInfo.InvariantCulture, "scope:\"{0}\"", "people");
            keywordQuery.SelectProperties.Add("FirstName");


            ResultTableCollection resultsCollection = keywordQuery.Execute();

            ResultTable resultsTable = resultsCollection[ResultType.RelevantResults];}

You can specify Select properties in KeywordQuery.SelectProperties and add filter conditions like scope in query text.

In central admin, i think you just need to ensure that your content source is crawled and you can start executing your keyword or fulltext queries.

Hope this helps.

Faiz
Thanks Faiz, I got really great information. Thanks once again. Let me try this. But question is still there of (I am not mentioned in question). My question is:I want to search information from Contact list. If any keyword I put in the search box (custom), I want render related information in our own specified format Group by Country. Which technique should I use here?
Lalit
Any updates over this???
Lalit
i think no updates, but this solution is useful in only few situations.
Lalit