Search results not having any connections with Smart Search Widget with page crawler index

santhoshkumar budhihal asked on July 11, 2016 12:46

Hi,

I have been trying to get the search working on my kentico website and the problem lies in order of results it is returning, i might be doing something wrong here ? Below are the details

Index type : Page crawler

Path in widget : /%

Search Sort :##SCORE## DESC (tried removing DESC, no luck)

Then i went through a FAQ, which had the statement like this but no joy

Condition : DocumentName:({% QueryString.searchtext %})

What does it mean set the DocumentName as searchable ? where will i find that ? gimme steps please ? Thanks in advance

Recent Answers


Trevor Fayas answered on July 11, 2016 20:06

The issue is either with your Smart Search settings or your Condition.

First, if you want the smart search to have "DocumentName" as a searchable field, in Kentico, go to the page type -> Search Fields, and make sure "Searchable" is checked for the field, this will mean it can be referenced directly.

Secondly, you may want to put quotes around the Search text, as non-quoted usually only works for a search parameter that has no spaces, as well as the syntax would be: DocumentName:"The search text"

Try those and tell me if that helps, make sure you build the index. There is a tool called "LUKE" that can inspect the actual index file and there you can see if the data is there to begin with. https://lingpipe-blog.com/2012/07/24/using-luke-the-lucene-index-browser-to-develop-search-queries/

1 votesVote for this answer Mark as a Correct answer

santhoshkumar budhihal answered on July 12, 2016 03:28 (last edited on December 10, 2019 02:30)

Hi Trevor,

Thank you for the response, however issue still persists after trying steps you have mentioned.

Currently the sort condition is : ##SCORE## Desc

Search Condition : DocumentName:"({% QueryString.searchtext |(identity)GlobalAdministrator%})^[boost value]

and then DocumentName: "QueryString.searchtext"

but none of this is helping me to improve search order

When I search for Venue,

First page results include

/venue/something1

/venue/something2

it is only after two pages the main keyword url appears as

/venue

We want /venue in the beginning itself, is there a way out ?

highly appreciate your time and co-operation, Thanks in advance

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on July 12, 2016 06:27

To get really boosted results, you probably want to look to set fields yourself and boost those specific ones. A while back i created a filter with boost attribute

double Weight = 2;
string searchLuceneValue = SearchSyntaxHelper.GetFilterCondition("MySearchField", "TheSearchValue");
searchLuceneValue  = isearchLuceneValue + "^"+Weight;

Something similar to that. I ended overwriting the DocumentEvents.GetContent.Execute Event (See Global Events) and modifying what pieces of data got stored where (ex e.SearchDocument.AddGeneralField("SearchableDocumentName", "The DocumentName", true, false)), and then boosting the weight of that tremendously, like "SearchableDocumentName:("Venue")^10.0" until i got the desired results.

Cloning the smart search filter and adding a weight made it a little easier to manage, sadly i don't have access to that site anymore so i can't export it (would need client permission if i did anyways)

0 votesVote for this answer Mark as a Correct answer

santhoshkumar budhihal answered on July 12, 2016 15:05 (last edited on December 10, 2019 02:30)

Hi Trevor,

Thank you for the spot on answer, I understood the logic here in this case.

You are trying to force the system to accept a particular keyword to show in the beginning of result.

Now here in this case, you are trying to assign the value on own, by declaring a 'double' variable.

In my case, can I go ahead and set this double value to 100 ? so that the result always returns in the following order when searched with venue keyword

/venue

/venue/something1

/venue/something2

am i right so far ?

if yes, where do i write this code ? in the searchresults.ascx.cs ? if yes then in which block ? which event ? I can see SearchHelper class with various properties in this file.

Sorry for stretching this beyond the limit but do help me on where to write this code and will it help me to get the /venue on the top ?

I somehow tried Search Condition : DocumentName:({% QueryString.searchtext |(identity)GlobalAdministrator%})^10 but no change at all

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on July 12, 2016 18:21

I would clone the Smart Search Filter control and add the weight logic there, that's what I did. It points to a Smart Search Results web part to apply additional filters.

I would try to first establish functionality. I would set the Document Name (in the Search tab of the Page Type) as a searchable parameter.

Then add a Smart Search Results web part, add a Smart Search Filter and try to use it to search for the DocumentName = "Venue" and first see if you can get just that result.

After you get that going, you can start using "Venue" for both the general search, but also a boosted specific search through the Smart Search Filter (adding the weight "^" to it).

To help you out further, in the CMSWebParts/SmartSearch/SearchFIlter.ascx.cs, look int he Page_Load around this line:

 private void AddItem(string row, string value, string displayName) {
 ...
 ListItem item = FilterIsConditional ? new ListItem(displayName, SearchSyntaxHelper.GetFilterCondition(row, value) ?? "") : new ListItem(displayName, row);
 ...
 }

This is where it builds ListItem with the Lucene logic. This is where you add your weight logic that i put above. I generated the ListItem's value seperately, then created the new List Item with it.

double Weight = 2;
string searchLuceneValue = SearchSyntaxHelper.GetFilterCondition("MySearchField", "TheSearchValue");
searchLuceneValue  = searchLuceneValue + "^"+Weight;
ListItem item = FilterIsConditional ? new ListItem(displayName, searchLuceneValue) ?? "") : new ListItem(displayName, row);

Try that out!

0 votesVote for this answer Mark as a Correct answer

santhoshkumar budhihal answered on July 13, 2016 09:12

Hi Trevor,

How are you doing today ? Hope everything is fine. Thank you for the response.

So do you suggest that we must have to add a search filter web part along with the smart search dialog with results web part ?

Can't we do it without adding that search filter web part ? Thanks

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on July 13, 2016 15:05

You may be able to, anything is possible, however the Smart Search Filter web part is exactly what you are looking for, to run a filter on the exact field that you want boosted. If you try to boost the general search, it won't do much because the general search will get a result with weights, and boosting all the results will still end up in the same weight order (ex, 1, .5, .5 boosted by 2 will be 2, 1, 1, same order).

You want to add a filter to boost results matching the DocumentName specifically.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.