Technical support This forum is closed.
Version 1.x > Technical support > Help me understand Search Modes in CMSSearchResults View modes: 
User avatar
Member
Member
trint99 - 9/6/2006 8:31:36 PM
   
Help me understand Search Modes in CMSSearchResults
I am using 1.9.2405 Pro.

I have two files uploaded. One file (File A) contains the phrase "Permissions Matrix". The other file (File B) contains the word "Permissions" but does not contain the word "Matrix".

I have configured my search page with a CMSSearchDialog and a CMSSearchResults.

protected void Page_Load(object sender, EventArgs e)
{
string searchString = WebProject.Functions.GetRequestValue( "searchtext", String.Empty );
if( !IsPostBack && !string.IsNullOrEmpty( searchString ) )
{
SearchDialog.SearchExpression = searchString;
SearchResults.SearchExpression = searchString;
SearchResults.CMSSearchDialogID = "";
}
else
{
SearchResults.CMSSearchDialog = SearchDialog;
}
}

If I search for "Permissions Matrix", the first time into the page, "Any Word" is the default mode and both File A and File B are returned. This is as I expect, because both files contain the word "Permissions".

If, in the SearchDialog, I set the search mode to "All Words" and search again, only File A is returned. This is as I expect, because File B does not contain the word "Matrix" and thus does not contain "All Words".

However, when I set the search mode to "Exact Phrase", both File A and File B are returned. My understanding is that, since File B does not contain the exact phrase "Permissions Matrix", it should not be returned.

I tried adding double quotes to the search string in the CMSSearchDialog's SearchExpression text box. With double quotes added, no matter what search mode I choose, both files are returned. Now I am REALLY confused.

Please help me understand what is happening.

User avatar
Guest
admin - 9/7/2006 4:58:00 PM
   
Re: Help me understand Search Modes in CMSSearchResults
Could you please check what value is actually set to the SearchResults.SearchMode value at the end of your Page_Load method?

Regards,

User avatar
Member
Member
trint99 - 9/13/2006 5:26:40 PM
   
Re: Help me understand Search Modes in CMSSearchResults
Sorry for the delay. I've been working on other parts of the project.

Here is my current Page_Load for the Search.aspx.cs page.

protected void Page_Load(object sender, EventArgs e)
{
string searchString = WebProject.Functions.GetRequestValue( "searchtext", String.Empty );
if( !IsPostBack && !string.IsNullOrEmpty( searchString ) )
{
SearchDialog.SearchExpression = searchString;
SearchResults.SearchExpression = searchString;
SearchResults.CMSSearchDialogID = "";
}
else
{
// $$DEBUG
Response.Write( SearchDialog.SearchMode.ToString() + "<br />" );
SearchResults.CMSSearchDialog = SearchDialog;
// $$DEBUG
Response.Write( SearchResults.CMSSearchDialog.SearchMode.ToString() + "<br />" );
Response.Write( SearchResults.SearchMode.ToString() + "<br />" );
}
}

Which results in the following:

Selector set to "Any Words"
AnyWord
AnyWord
AnyWord
Both documents listed (correctly).

Selector set to "All Words"
AllWords
AllWords
AnyWord
Only one document listed (correctly).

Selector set to "Exact Phrase"
ExactPhrase
ExactPhrase
AnyWord
Both documents listed (incorrectly).

User avatar
Guest
admin - 9/13/2006 6:06:30 PM
   
Re: Help me understand Search Modes in CMSSearchResults
It seems the SearchResults.SearchMode is not set correctly. You may need to modify your code like this:

if( !IsPostBack && !string.IsNullOrEmpty( searchString ) )
{
SearchDialog.SearchExpression = searchString;
SearchResults.SearchExpression = searchString;
SearchResults.CMSSearchDialogID = "";
}
else
{
// $$DEBUG
Response.Write( SearchDialog.SearchMode.ToString() + "<br />" );
SearchResults.CMSSearchDialog = SearchDialog;

// *********************** ADD ***********************
SearchResults.SearchMode = SearchDialog.SearchMode;
// *********************** END ADD ***********************


// $$DEBUG
Response.Write( SearchResults.CMSSearchDialog.SearchMode.ToString() + "<br />" );
Response.Write( SearchResults.SearchMode.ToString() + "<br />" );
}

Best Regards,

User avatar
Member
Member
trint99 - 9/14/2006 5:45:54 PM
   
Re: Help me understand Search Modes in CMSSearchResults
I added the line of code to explicitly set the SearchResults.SearchMode. As you would expect, the search mode now matches that of the SearchDialog. However, the results of the search are the same. "Exact Phrase" is not excluding the file in which the exact phrase does not occur. Is it possible that there is a logic error in the Exact Phrase search algorithm?