Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Filtering Smart Search results View modes: 
User avatar
Member
Member
lancetek - 12/1/2011 10:08:01 AM
   
Filtering Smart Search results
I have a smart search index for Article document types. How can I use a smart search filter to filter by Owner and NodeParentId?

Owner and NodeParentId are not actually defined as part of the Article document type - do I need to create a different search index and join them to the Article search index?

User avatar
Member
Member
lancetek - 12/1/2011 11:30:07 AM
   
RE:Filtering Smart Search results
In a related vein: How / where can I see what fields are used by the smart search? For example, in the 'search condition' field I am using the NodeLinkedNodeID property - where can I see a list of others that I can also populate the search condition with?

User avatar
Member
Member
lancetek - 12/1/2011 4:33:55 PM
   
RE:Filtering Smart Search results
NOTE: I've phoned Kentico for support for this issue, since it's taking way too long to figure out, so I'll update this post to keep everyone in the loop and help future searchers!

Here's the email to support:


I've got a smart search with results web part and in the search condition I have tried variations on:

+NodeOwner:(int)6497

+NodeOwner:[6491]

But when I use this, I get no results back. I can query the database:

SELECT distinct NodeOwner, NodeOwnerFullName, NodeOwnerUserName, NodeOwnerEmail
FROM View_CONTENT_article_Joined
WHERE Published = 1 AND NodeOwnerFullName != '' and NodeOwnerFullName is not null
ORDER BY NodeOwnerFullName

And I can see that one of the NodeOwner fields contains 6497 or 6491, so these seem to be valid integer values to use in the search.

After getting off the phone with Edward, I found a tool to read the Lucene index - LUKE - download the 'binary' version and run on the command line like: java -jar lukeall-3.4.0_1.jar

But in any case, when examining the index, I see that some of the integer fields are 'padded' - for example I can find a document with the nodeowner of '10000006479' - so some of the integer fields in the index are 11 characters long, while others are just normal integer, nodeid for example is just 10176

Using LUKE, the queries that I was using such as +NodeOwner:(int)6497 or +NodeOwner:[6491] fail. But if I do a query like: nodeowner:10000006479, I get results.

I tried creating a new index for the Article document type to see if there is any change in this strangeness, but the new index has the same structure... no surprise, but dissapointing nonetheless!


So do I need to do something special to query these 'padded' fields?

I've attached a zip of the index so that you can see for yourself what my index looks like.


I've intercepted the searchText that's send to Lucene in the \website\CMSModules\SmartSearch\Controls\SearchResults.ascx.cs file, ln 1271 Here's an example where I'm trying to fetch documents for the Owner #6479

+(') +_culture:([en-gb TO en-gb] [invariantifieldivaluei TO invariantifieldivaluei]) +( nodeowner:6479 )


Of course this brings back a blank result set since it isn't padded with the extra digits.

In looking at the index again it appears that only two of the integer fields are NOT padded: documentId and nodeId. Both of these are the primary keys of their respective tables. It's starting to smell like a bug with the index creation module in Kentico...


User avatar
Kentico Support
Kentico Support
kentico_janh - 12/6/2011 2:39:15 AM
   
RE:Filtering Smart Search results
Hello,

Yes, only integer primary key fields are not formated into that long number. As it is described in our documentation (+DocumentCreatedByUserID;(int)53;Administrator), you need to specify, what data type is returned value.

So the query needs to be prepare for a value conversion:

SELECT TOP 1 '+DocumentCreatedByUserID', '(int)' + CONVERT(varchar, DocumentCreatedByUserID) , 'Admin'
FROM CMS_Document
WHERE DocumentCreatedByUserID = 53


Best regards,
Jan Hermann