Hallo guys! Im making some search functionality for a umbraco site, and my own knowledge dosn't get me to where i want to be, so hopefully some of you might know anything about what i would like to achieve.
the goal is to have a normal searchbox where users can search normally and get the best results compared to the string / term they searched. So a fairly standard searchfunctionality.(but isn't all search about that? ;) )
I got a few fields i want to search in, and some has some special circumstances:
bodyText - Textfield for content. Borger - A field which a article is put into at index-time. (can the indexwriter strip HTML-tags?) nodeName - Headline for the node.
Search-string is: nyt pas. (new passport)
i would like to have search in these 3 fields, and get the most relevevant document depending on the search-strings content. in practice the searchstring could be 1 word or more.
and getting results i did, and as far as i could se they made sense with the following code:
But, now comes the tricky part. On a node there are 2 fields more:
Keyword: Keywords the editor puts on the node to describe it, comma separated words. Best Guess: is the editors Best Guess for searching, to find this node. Fx. Get new password. these best guess are comma separated phrases.
What i would like to end up with, is if one or more of the search-terms in the string, is in the keyword list it should get boosted, the more terms matching, the more it's boosted. And likewise with Best guess, if the searched prhase is the same as in Best Guess, then this should get boosted(alot, due to the editor took that node to match that phrase).
I've made the following, but the score is lower with keywords added to the query, though the searched term "pas" is in the keywords field. In my head, it should have a even highere score, due to the extra field(keywords) also contains the searched word(pas), but it dosn't.
var terms = searchString.Contains(" ") ? searchString.Split(' ') : new string[] {searchString};
var fields = new string[] {"bodyText", "Borger", "nodeName"};
var query = searchCriteria.GroupedOr(fields, terms).Or().GroupedOr(new string[] { "keyWords" }, terms).Compile();
The right build for examine query
Hallo guys!
Im making some search functionality for a umbraco site, and my own knowledge dosn't get me to where i want to be, so hopefully some of you might know anything about what i would like to achieve.
the goal is to have a normal searchbox where users can search normally and get the best results compared to the string / term they searched. So a fairly standard searchfunctionality.(but isn't all search about that? ;) )
I got a few fields i want to search in, and some has some special circumstances:
bodyText - Textfield for content.
Borger - A field which a article is put into at index-time. (can the indexwriter strip HTML-tags?)
nodeName - Headline for the node.
Search-string is: nyt pas. (new passport)
i would like to have search in these 3 fields, and get the most relevevant document depending on the search-strings content. in practice the searchstring could be 1 word or more.
and getting results i did, and as far as i could se they made sense with the following code:
searchCriteria.GroupedOr(new string[] { "bodyText", "Borger", "nodeName" }, searchString.Split(' ')).Compile();
But, now comes the tricky part.
On a node there are 2 fields more:
Keyword: Keywords the editor puts on the node to describe it, comma separated words.
Best Guess: is the editors Best Guess for searching, to find this node. Fx. Get new password. these best guess are comma separated phrases.
What i would like to end up with, is if one or more of the search-terms in the string, is in the keyword list it should get boosted, the more terms matching, the more it's boosted.
And likewise with Best guess, if the searched prhase is the same as in Best Guess, then this should get boosted(alot, due to the editor took that node to match that phrase).
I've made the following, but the score is lower with keywords added to the query, though the searched term "pas" is in the keywords field. In my head, it should have a even highere score, due to the extra field(keywords) also contains the searched word(pas), but it dosn't.
var terms = searchString.Contains(" ") ? searchString.Split(' ') : new string[] {searchString};
var fields = new string[] {"bodyText", "Borger", "nodeName"};
var query = searchCriteria.GroupedOr(fields, terms).Or().GroupedOr(new string[] { "keyWords" }, terms).Compile();
Can anyone guide me in the right direction ?
Thanks alot
is working on a reply...