26 January 2011

Manage queries and result with Search Server

Search server has a number of built in logic features that allows for things like plural searches etc.  But if you really want to customize search results you would want to do some tweaking in how the queries are handled.

There are a few files that can make a huge difference if you configure them to suit your environment.

  • Stop File
  • Thesaurus file
  • Custom Dictionary file
Stop File
The stop file basically eliminates certain words form the query.  As an example if you search for "The blog of choice" the words "The" and "of" will be eliminated because they are too generic to add any value to search results.  You might want to add potentially offensive words, company name etc.

To add additional words to eliminate you need to:

  • Browse to  %ProgramFiles%\Microsoft Office Servers\14.0\Data\Applications\GUID\Config
  • Edit the noiseenu.txt file
  • Add the additional stop words and save the file.
  • Restart the SharePoint Server Search 14 service

Thesaurus file
This xml file allows you to replace search query terms or to specify synonyms (expansion) to include in a query.  

As an example for a replace, if you search for "The blog of choice" you can replace the word "blog" with "web site" to the query being sent will turn into "The web site of choice"

As an example of a synonym you can expand the word "blog" to also include the word "web site."  The query being sent will then turn into ""The blog or web site of choice"

  • Browse to  %ProgramFiles%\Microsoft Office Servers\14.0\Data\Applications\GUID\Config
  • Edit the tsneu.xml file
  • Remove the <!-- Commented out
  • Remove the -->
  • Add your own expansion or replacement
  • Restart the SharePoint Server Search 14 service

Here is an example file to show you the structure.

<XML ID="Microsoft Search Thesaurus">

<!--  Commented out

    <thesaurus xmlns="x-schema:tsSchema.xml">
        <diacritics_sensitive>0</diacritics_sensitive>
        <expansion>
            <sub>Internet Explorer</sub>
            <sub>IE</sub>
            <sub>IE8</sub>
        </expansion>
        <replacement>
            <pat>NT5</pat>
            <pat>W2K</pat>
            <sub>Windows 2000</sub>
        </replacement>
        <expansion>
            <sub>run</sub>
            <sub>jog</sub>
        </expansion>
    </thesaurus>
-->
</XML>

Not too tricky to follow.

Custom dictionary file
This is probably not the best name for it. But it is what it is.  A dictionary file can be used to prevent "normal substitution" of special characters, called word breakers. As an example if you search for the name "Blog&Go" the query will be broken up and return result for "blog" and "go" by including "Blog&Go" in the dictionary file it prevents this from happening.

There are some rules to dictionary files check out  http://technet.microsoft.com/en-us/library/cc262507.aspx for more information in this.

To add a custom dictionary file you need to:

  • Browse to %ProgramFiles%\Microsoft Office Servers\14.0\Bin.
  • Create a textfile named Custom0009.lex  (this is the filename for English - see the above link for other language file names)
  • Edit the file and add the dictionary words, one per line.
  • Save the file
  • Stop and start the SharePoint Server Search 14 service
  • Perform a full crawl

Bypassing these settings
All the setting and function provided by the above files can be bypassed by doing a literal search.  as an example if you want to search for and only for "The blog of choice" you can force this by including the quotation marks.


Conclusion
By using all or some of the files above you can fine tune how the queries are submitted and handled.  This in turn will return more relevant results.

For more information about this you can check out the "not so easy to read TechNet articles http://technet.microsoft.com/en-us/library/cc179583.aspx


No comments:

Post a Comment