API Questions on Kentico API.
Version 6.x > API > Smart Search - debug generated query View modes: 
User avatar
Member
Member
yevgen.fesenko-bellmedia - 10/26/2012 10:37:33 AM
   
Smart Search - debug generated query
I'm using Smart Search to do some data retrieval in Kentico 6 without using existing CMS controls.

I use the SearchHelper.Search() method in conjunction with SearchHelper.CombineSearchCondition() to generate the query.

Search Condition I generate using CombineSearchCondition() is correct and I can query Lucene index (through Luke).

However, when I do SearchHelper.Search, I get no results back.

Is there any way see the full query that's being sent to Lucene when I use SearchHelper.Help()?

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 10/28/2012 9:19:52 AM
   
RE:Smart Search - debug generated query
Hi,

I did not find Help method in the SearchHelper. The api example for searching using Search method you can find here:
search api exaple

You can see the search text (including filters) in the searchText parameter, so if you run a debug, you will see what is sent to lucene.

Here is a more complex example which searches according to the longitute and latitude:

string combinedSearch = "+(+longitude:[10000000048.9707534505 TO 10000000049.1502705495]) +classname:[cms.news TO cms.news] +_culture:([en-us TO en-us] [invariantifieldivaluei TO invariantifieldivaluei]) ";
string path = "";
string DocumentTypes = "CMS.News";
string culture = "en-US";
string defaultCulture = "en-US";
bool CombineWithDefaultCulture = false;
bool CheckPermissions = false;
bool SearchInAttachments = false;
string Indexes = "CorporateSite.Default";
int displayResults = 10;
int startPosition = 0;
int numberOfProceeded = 110;
int numberOfResults = 0;
UserInfo user = UserInfoProvider.GetUserInfo(CMSContext.CurrentUser.UserName);

DataSet results = SearchHelper.Search(combinedSearch,
SearchHelper.GetSort("##SCORE##"),
path,
DocumentTypes,
culture,
defaultCulture,
CombineWithDefaultCulture,
CheckPermissions,
SearchInAttachments,
Indexes,
displayResults,
startPosition,
numberOfProceeded,
user,
out numberOfResults,
"",
"");

}


Best regards,
Ivana Tomanickova

User avatar
Member
Member
yevgen.fesenko-bellmedia - 10/29/2012 8:26:05 AM
   
RE:Smart Search - debug generated query
Thank you for your response, Ivana,

I've done exactly the same thing.

The "combined search" query that is generated returns correct results when I use the Luke utility (http://www.getopt.org/luke/). However, when I put it into SearchHelper.Search() along with other parameters, result DataSet is null.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 10/31/2012 8:55:15 AM
   
RE:Smart Search - debug generated query
Hi,

there will be something wrong in parameters of the method.

You can do a simple test to check the values of method.

You can configure smart search dialog, filter and result web part. It is fast and then you can check paramaters of the method in the search result control:

C:\<project>\CMSModules\SmartSearch\Controls\SearchResults.ascx.cs


(in the Search() method).

If you run the project mode you can directly see the result.

Maybe your code is using incorerct index, definition od document types is missing or you are using incorrect path or culture version. It is difficult to say.

Best regards,
Ivana Tomanickova