Reputation: 124
I work with the Kentico smart search.
I want to boost smart search results relevance scope.
I read this article that describes how to do it with a bool field.
According the article I have to create in a Kentico page type a bool column and then setup to the Search condition
field of a smart search control this code:
columnname:(true)^3
If a required page contains this column and its value is true
then this page relevance will be increased.
It works.
Now I'd like to do the same with an integer column. I want to keep in this column a coefficient that allows to increase the relevance.
I know that the Kentico uses the Apache Lucene search engine that I 've never use before. I found some examples and suggested that I have to setup to the Search condition
field something like this:
columnname:(0)^0 columnname:(1)^1 columnname:(2)^2
I expect that the search results relevance scope will be increased according the value of the columnname
.
It doesn't work.
Which syntax I have to use to achieve my goal if it's possible
Upvotes: 0
Views: 438
Reputation: 4325
Kentico by default stores integers in a special format. You therefore need to convert your integers to this format when building your query. Assuming you're building your query in code, you can do this with Kentico's helper method SearchValueConverter.IntToString(id)
where id
references your integer value. This code is untested, but you'll need something like:
string.Format(
"columnname:({0})^0 columnname:({1})^1 columnname:({2})^2",
SearchValueConverter.IntToString(id1),
SearchValueConverter.IntToString(id2),
SearchValueConverter.IntToString(id3))
Upvotes: 1
Reputation: 998
If understand correctly you want to give a boost depending on single column value so each document contains boost value column (or their weight)
Essentially each document contains its weight (boost) value right? Try something like this (assuming columnname is the column name in lucene index and your document type):
columnname:(int){%columname%}^{%columname%}
I am not sure about your architecture, but in this case you can simply create a sort (which is your boost column) column and sort results by this sort column? They will be sorted by sort column, then by relevance inside
Upvotes: 0