MOSS 2007 People search influenced by synonym list by user language and setting the rowlimit on a query greater than 50.

This post is an addition to my previous post about SharePoint people search.

While building a custom “CoreResultsWebPart” we noticed that some people were not being returned in our search results by the default search.

1) But when we searched it with our custom code it did return results.

2) When a french speaking collegue of mine searched using the same webpart he did get the result, but only when he logged into the machine, not just by signing into my IE Sharepoint.

When going to the SharePoint logs I found that the query did the following when I searched for “Leemans”:

<QueryID>0x231c0031</QueryID><RstCollection Count=”1″><RstTree><Rst Type=”Prob” Count=”3″><Rst

Type=”Synonym“><Occ>1</Occ><Keys Count=”4″><Key PID=”0x7fff7fff” len=”7″>0x00006c00650065, lee</Key><Key

PID=”0x7fff7fff” len=”13″>0x00006c00650065006d0061006e, leeman</Key><Key PID=”0x7fff7fff”

len=”19″>0x00006c00650065006d0061006e006e0065006e, leemannen</Key><Key PID=”0x7fff7fff”

len=”15″>0x00006c00650065006d0061006e0073, leemans</Key></Keys></Rst><Rst Type=”Synonym“><Occ>1</Occ><Keys

Count=”3″><Key PID=”0x7fff7fff” len=”7″>0x00006d0061006e, man</Key><Key PID=”0x7fff7fff”

len=”13″>0x00006d0061006e006e0065006e, mannen</Key><Key PID=”0x7fff7fff” len=”9″>0x00006d0061006e0073,

mans</Key></Keys></Rst><Rst Type=”And” Count=”1″><Rst

So the query automatically (also for out of the box Sharepoint people search!) used synonyms to change my queryterms.

After some Reflector work on the “SearchResultHiddenObject” class I found the following:

   1: try

   2:                 {

   3:                     if (!string.IsNullOrEmpty(this._QueryLanguage))

   4:                     {

   5:                         myRequest.Culture = new CultureInfo(this._QueryLanguage);

   6:                     }

   7:                     else if ((this.thisPage.Request.UserLanguages != null) &&


   9: (this.thisPage.Request.UserLanguages.Length > 0))

  10:                     {

  11:                         myRequest.Culture = new CultureInfo(this.thisPage.Request.UserLanguages[0]);

  12:                     }

  13:                 }


Which means if the param _QueryLanguage isn’t filled in, it used the users language which explains why my french speaking collegue did get results. The french synonym list wasn’t creating issue’s, nor was the english one, just dutch.\n

By adding the following code to my already custom webpart I could set the parameter and garanty that each user use the same, english synonym list.\n

+ I added some code so the maximum returned results by a query isn’t limited to 50.



   1: public class xxxwebpart: CoreResultsWebPart


   3: {


   5: ....


   7: protected override void SetPropertiesOnHiddenObject()


   9: {


  11: base.SetPropertiesOnHiddenObject();


  13: // Get Reflection info


  15: object srho = this.GetType().InvokeMember("srho", BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic, null, this, new object[] { });


  17: Type type = srho.GetType();


  19: //Set RowLimit


  21: type.InvokeMember("_ResultsRequested", BindingFlags.SetField | BindingFlags.Instance | BindingFlags.NonPublic, null, srho, new object[] { ((short)1000) });


  23: //Set Query Culture to en-GB to use this synonym list which causes no problems


  25: type.InvokeMember("QueryLanguage", BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.Public, null, srho, new object[] { "en-GB" });


  27: // Allow the query to be reissued


  29: type.InvokeMember("ForceRerun", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public, null, srho, new object[] { });


  31: }



Seeing as the dutch synonym list was not changed but default, I think we can assume all the out of the box people searches for Dutch users will sometimes give no results because of the synonym use…\n

As a quick fix for users that don’t use a custom CoreSearchResults webpart I’ve created a simple webpart called SearchQueryOptionsWebPart that does 2 things:\n

– Sets the culture for the query so you can determine per page which Culture (read which synonymlist) should be used by all users.\n

– Sets the rowLimit for the query to return. I’ve noticed that a lot of people are also looking for an easy way to increase this above the hard limit of 50.\n

You can find the sourcecode here.\n

Just install the wsp, activate the site collection feature “MOSS2007 Search Query Options WebPart (SQOW) ” and add the webpart to any search result page where you want to set the options.\n

The default for the options are “en-GB” and 1000 (rowlimit) but you can change these easily in the webpart properties.\n




leave your comment