Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Application Crash when using "Not" in the search field View modes: 
User avatar
Member
Member
andy-procaresoftware - 9/10/2012 1:29:13 PM
   
Application Crash when using "Not" in the search field
Greetings, we're experiencing some oddities in search when using "All Words" and "Exact phrase" and using the search term "Not" or term with "Not" (Could not be) in it.

Current version is 6.0.41.

Is this a known previous issue and has this been fixed in a recent hotfix?

User avatar
Member
Member
andy-procaresoftware - 9/10/2012 1:49:01 PM
   
RE:Application Crash when using "Not" in the search field
Additionally - we've notice that exact phrase search with the word "Not" in them become "Any Word" searches. This can also be repeated here on your web site. Do an exact phrase search for "Should not be" and you will see results with onlty "should" in the results.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 9/11/2012 5:33:13 AM
   
RE:Application Crash when using "Not" in the search field
Hi,

What do you mean exactly by the crash? Could you please elaborate more on this?

Regarding the "not" word - it is a part of the Lucene.Net syntax - it is a stop or noise word used by the analyzer.

So, you may need to change the analyzer type used for your index or create a custom analyzer to work with this word.
Another option is to define the stop words for English excluding "not" and adding the txt file into App_Data\CMSModules\SmartSearch\_StopWords\ folder and then select this stop words option in the index settings.

Best regards,
Juraj Ondrus

User avatar
Member
Member
andy-procaresoftware - 9/12/2012 12:23:19 PM
   
RE:Application Crash when using "Not" in the search field
By "crash" I means "Server Error in "/" Application

We applied all current hot fixes hoping for a fix but we still have the problem when we enter "not" in an All Word search. Below is the stack trace.
Object reference not set to an instance of an object. 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
CMS.SiteProvider.SearchHelper.Search(String searchFor, Sort searchSort, String path, String classNames, String currentCulture, String defaultCulture, Boolean combineWithDefaultCulture, Boolean checkPermissions, Boolean searchInAttachments, String searchIndexes, Int32 displayResults, Int32 startingPosition, Int32 numberOfProcessedResults, UserInfo user, Int32& numberOfResults, String attachmentWhere, String attachmentOrderBy) +4090
CMSModules_SmartSearch_Controls_SearchResults.Search() +872
CMSModules_SmartSearch_Controls_SearchResults.OnPreRender(EventArgs e) +16
System.Web.UI.Control.PreRenderRecursiveInternal() +80
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

What analyzer type do you recommend? I expect all of them to work with this happening.

User avatar
Member
Member
andy-procaresoftware - 9/12/2012 12:38:21 PM
   
RE:Application Crash when using "Not" in the search field
Here is the search for "Could Not Be" all words
Server Error in '/' Application.
--------------------------------------------------------------------------------

Syntax error near 'be' in the full-text search condition '(could AND not AND be)'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Syntax error near 'be' in the full-text search condition '(could AND not AND be)'.

Stack Trace:

[SqlException (0x80131904): Syntax error near 'be' in the full-text search condition '(could AND not AND be)'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1953274
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849707
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +33
System.Data.SqlClient.SqlDataReader.get_MetaData() +96
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +297
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +141
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +12
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +10
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +130
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +287
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +94
CMS.DataProviderSQL.DataConnection.ExecuteQuery(String queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, Boolean requiresTransaction) +174

[Exception: [DataConnection.HandleError]: Query: SELECT SUM(RANK) AS [Score], DocumentID, SiteName, NodeID, NodeAliasPath, DocumentCulture, NodeClassID, ClassName, NodeACLID, NodeSiteID, NodeLinkedNodeID, NodeOwner
FROM CMS_Attachment INNER JOIN
CONTAINSTABLE(CMS_Attachment, AttachmentBinary, '(could AND not AND be)' ) AS KEY_TBL ON CMS_Attachment.AttachmentID = KEY_TBL.[KEY] INNER JOIN
View_CMS_Tree_Joined ON View_CMS_Tree_Joined.DocumentID = CMS_Attachment.AttachmentDocumentID
WHERE (Published = 1) AND (((View_CMS_Tree_Joined.DocumentSearchExcluded IS NULL) OR (View_CMS_Tree_Joined.DocumentSearchExcluded = 0)) AND (DocumentCulture = N'en-US') AND (NodeSiteID IN (1)) )
GROUP BY DocumentID, SiteName, NodeID, NodeAliasPath, DocumentCulture, NodeClassID, ClassName, NodeACLID, NodeSiteID, NodeLinkedNodeID, NodeOwner ORDER BY Score DESC: caused exception: Syntax error near 'be' in the full-text search condition '(could AND not AND be)'.]
CMS.DataEngine.AbstractDataConnection.HandleError(String queryText, SqlException ex) +87
CMS.DataProviderSQL.DataConnection.ExecuteQuery(String queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, Boolean requiresTransaction) +212
CMS.DataEngine.AbstractDataConnection.CMS.SettingsProvider.IDataConnection.ExecuteQuery(String queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, Boolean requiresTransaction) +18
CMS.DataEngine.GeneralConnection.RunQuery(QueryParameters query) +200
CMS.DataEngine.GeneralConnection.ExecuteQuery(QueryParameters query) +370
CMS.DataEngine.GeneralConnection.ExecuteQuery(String queryName, QueryDataParameters parameters, String where, String orderBy, Int32 topN, String columns) +106
CMS.DataEngine.ConnectionHelper.ExecuteQuery(String queryName, QueryDataParameters parameters, String where, String orderBy, Int32 topN, String columns) +52
CMS.TreeEngine.TreeProvider.AttachmentSearch(String searchExpression, String path, String className, String where, String orderBy, Int32 topN, Boolean checkPermissions, Boolean combineWithDefaultCulture, String culture, String defaultCulture, Int32[] siteIds, UserInfo user) +1263
CMS.TreeEngine.TreeEngineModule.ProcessCommand(String commandName, Object[] parameters) +1580
CMS.SettingsProvider.ModuleEntry.ProcessModuleCommand(String moduleName, String commandName, Object[] parameters) +27
CMS.SettingsProvider.ModuleCommands.AttachmentSearch(String searchExpression, String path, String className, String where, String orderBy, Int32 topN, Boolean checkPermissions, Boolean combineWithDefaultCulture, String culture, String defaultCulture, Int32[] siteIds, BaseInfo userInfo) +265
CMS.SiteProvider.SearchHelper.Search(String searchFor, Sort searchSort, String path, String classNames, String currentCulture, String defaultCulture, Boolean combineWithDefaultCulture, Boolean checkPermissions, Boolean searchInAttachments, String searchIndexes, Int32 displayResults, Int32 startingPosition, Int32 numberOfProcessedResults, UserInfo user, Int32& numberOfResults, String attachmentWhere, String attachmentOrderBy) +3587
CMSModules_SmartSearch_Controls_SearchResults.Search() +872
CMSModules_SmartSearch_Controls_SearchResults.OnPreRender(EventArgs e) +16
System.Web.UI.Control.PreRenderRecursiveInternal() +80
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

User avatar
Member
Member
andy-procaresoftware - 9/12/2012 1:15:20 PM
   
RE:Application Crash when using "Not" in the search field
Here is what one of our Developers found.

To get the error enable "Search Attachments" in the Smart Search dialog with results web part and we get the errors. Index is using "subset" analyzer type. We have done this on two separate test installations and get the same result.

Again this is searching "could not be" All Words.


User avatar
Kentico Support
Kentico Support
kentico_jurajo - 9/13/2012 1:12:40 AM
   
RE:Application Crash when using "Not" in the search field
Hi,

thank you for the information. I just want to be sure - havbe you configured the SQL server for searchning in attachments and have you followed the documentation on how to search in attachments and all the pre-requisities?

It seems that the full text search is not configured.

Best regards,
Juraj Ondrus

User avatar
Member
Member
wade-procaresoftware - 9/14/2012 1:21:29 PM
   
RE:Application Crash when using "Not" in the search field
Juraj-

The full text search was already configured per the instructions on your site, but the issue is in the way the search expression is being passed from Kentico to the SQL server. The query shown in the exception text that Andy posted above will NOT run in a SQL query analyzer because the search expression's keywords have not been escaped correctly, and "not" is a reserved word:
SELECT SUM(RANK) AS [Score], DocumentID, SiteName, NodeID, NodeAliasPath, DocumentCulture, NodeClassID, ClassName, NodeACLID, NodeSiteID, NodeLinkedNodeID, NodeOwner
FROM CMS_Attachment INNER JOIN
CONTAINSTABLE(CMS_Attachment, AttachmentBinary, '(could AND not AND be)' ) AS KEY_TBL ON CMS_Attachment.AttachmentID = KEY_TBL.[KEY] INNER JOIN
View_CMS_Tree_Joined ON View_CMS_Tree_Joined.DocumentID = CMS_Attachment.AttachmentDocumentID
WHERE (Published = 1) AND (((View_CMS_Tree_Joined.DocumentSearchExcluded IS NULL) OR (View_CMS_Tree_Joined.DocumentSearchExcluded = 0)) AND (DocumentCulture = N'en-US') AND (NodeSiteID IN (1)) )
GROUP BY DocumentID, SiteName, NodeID, NodeAliasPath, DocumentCulture, NodeClassID, ClassName, NodeACLID, NodeSiteID, NodeLinkedNodeID, NodeOwner ORDER BY Score DESC

SQL sees the search keyword "not" as a logical operator in this query because it hasn't been escaped. If you escape the keywords properly, the query runs successfully:
SELECT SUM(RANK) AS [Score], DocumentID, SiteName, NodeID, NodeAliasPath, DocumentCulture, NodeClassID, ClassName, NodeACLID, NodeSiteID, NodeLinkedNodeID, NodeOwner
FROM CMS_Attachment INNER JOIN
CONTAINSTABLE(CMS_Attachment, AttachmentBinary, '("could" AND "not" AND "be")' ) AS KEY_TBL ON CMS_Attachment.AttachmentID = KEY_TBL.[KEY] INNER JOIN
View_CMS_Tree_Joined ON View_CMS_Tree_Joined.DocumentID = CMS_Attachment.AttachmentDocumentID
WHERE (Published = 1) AND (((View_CMS_Tree_Joined.DocumentSearchExcluded IS NULL) OR (View_CMS_Tree_Joined.DocumentSearchExcluded = 0)) AND (DocumentCulture = N'en-US') AND (NodeSiteID IN (1)) )
GROUP BY DocumentID, SiteName, NodeID, NodeAliasPath, DocumentCulture, NodeClassID, ClassName, NodeACLID, NodeSiteID, NodeLinkedNodeID, NodeOwner ORDER BY Score DESC

Please have a developer look into this issue for us.

Thank you!

User avatar
Member
Member
andy-procaresoftware - 9/17/2012 6:30:56 PM
   
RE:Application Crash when using "Not" in the search field
Have you guys had the time to look into this?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 9/18/2012 9:26:19 AM
   
RE:Application Crash when using "Not" in the search field
Hi,

I got it know, I missed one thing at the beginning. I am sorry for the confusion.
The replies on forums are not guaranteed to be on a timely matter. You can use our support e-mail address to receive the replies faster (usually within one business day) or you can also use our Premium support to have a guaranteed response and resolution.

Regarding the issue, thank you for letting us know about this issue. Regrettably, this seems to be a bug in the current version. I'm very sorry for this inconvenience. We will try fix it in the next version or in the next hotfix package for this particular Kentico CMS version.

Best regards,
Juraj Ondrus

User avatar
Member
Member
andy-procaresoftware - 9/19/2012 5:06:01 PM
   
RE:Application Crash when using "Not" in the search field
Thank you

User avatar
Member
Member
tsaregradskiy-gmail - 11/29/2013 5:37:53 AM
   
RE:Application Crash when using "Not" in the search field
Hi Juraj, I am setting up a SmartSearch.
Anyway the system searches attachments using the Microsoft SQL Server full‑text search.
Is there a possibility modify JOIN statement as shown below?
SELECT SUM(RANK) AS [Score], DocumentID, SiteName, NodeID, NodeAliasPath, DocumentCulture, NodeClassID, ClassName, NodeACLID, NodeSiteID, NodeLinkedNodeID, NodeOwner
FROM CMS_Attachment INNER JOIN
CONTAINSTABLE(CMS_Attachment, AttachmentBinary, '("could" AND "not" AND "be")' ) AS KEY_TBL ON CMS_Attachment.AttachmentID = KEY_TBL.[KEY] INNER JOIN
View_CMS_Tree_Joined ON View_CMS_Tree_Joined.DocumentID = CMS_Attachment.AttachmentDocumentID
WHERE (Published = 1) AND (((View_CMS_Tree_Joined.DocumentSearchExcluded IS NULL) OR (View_CMS_Tree_Joined.DocumentSearchExcluded = 0)) AND (DocumentCulture = N'en-US') AND (NodeSiteID IN (1)) )
GROUP BY DocumentID, SiteName, NodeID, NodeAliasPath, DocumentCulture, NodeClassID, ClassName, NodeACLID, NodeSiteID, NodeLinkedNodeID, NodeOwner ORDER BY Score DESC

change to

SELECT SUM(RANK) AS [Score], DocumentID, SiteName, NodeID, NodeAliasPath, DocumentCulture, NodeClassID, ClassName, NodeACLID, NodeSiteID, NodeLinkedNodeID, NodeOwner
FROM CMS_Attachment INNER JOIN
CONTAINSTABLE(CMS_Attachment, AttachmentBinary, 'FormsOf(inflectional,"could") and FormsOf(inflectional,"not") and FormsOf(inflectional,"be")' ) AS KEY_TBL ON CMS_Attachment.AttachmentID = KEY_TBL.[KEY] INNER JOIN
View_CMS_Tree_Joined ON View_CMS_Tree_Joined.DocumentID = CMS_Attachment.AttachmentDocumentID
WHERE (Published = 1) AND (((View_CMS_Tree_Joined.DocumentSearchExcluded IS NULL) OR (View_CMS_Tree_Joined.DocumentSearchExcluded = 0)) AND (DocumentCulture = N'en-US') AND (NodeSiteID IN (1)) )
GROUP BY DocumentID, SiteName, NodeID, NodeAliasPath, DocumentCulture, NodeClassID, ClassName, NodeACLID, NodeSiteID, NodeLinkedNodeID, NodeOwner ORDER BY Score DESC

BR, Dmitry

User avatar
Kentico Support
Kentico Support
kentico_romank - 1/6/2014 7:42:30 AM
   
RE:Application Crash when using "Not" in the search field
Hi,

Regrettably this is possible only if you have Kentico CMS with source code. Have you bought Kentico CMS licence with source code? If yes, please let me know and I will try to provide you solution.

Best Regards,
Roman Konicek