Press Ctrl / CMD + C to copy this to your clipboard.
Copied to clipboard
Flag this post as spam?
This post will be reported to the moderators as potential spam to be looked at
Topic author was deleted
Apr 08, 2016 @ 08:19
Examine/Lucene boosting relative to current site section
Hi all,
I'm implementing a search on a site using examine and have the following requirement.
Let's say the site structure is as follows
- Site
--- Section 1
------ Subpage ( content contains word bacon)
------- Another subpage
--- Section 2
------ Subpage ( content contains word bacon)
So if I search for bacon I get 2 results which is good! But how can I make it possible that depending on which section of the site you are on the result of that section is shown first in the results?
Currently I'm adding the section name to the index (in a new field called section)
and also passing that to the search page ?q=bacon§ion=general
Of course if I add an or to the query Or().Field("section", sectionValue); I get all pages that are under that section.... and not only the pages that contain the word bacon
So I need a way of boosting without actually searching for the section term...
How would you accomplish that? All help appreciated!
I'm only used to writing the raw queries, so you can write something like section:general^2 (the ^2 is the boost).
If using the chained method approach as in your example, I believe there is a Boost() method as well. Eg. something like Or().Field("section", sectionValue).Boost(2).
Thanks but the main issue I want to sort is that I don't want to search for the section just boost the main result if it's in that section, not sure if that's possible :)
Since I don't want to return all pages of that section, I just want to make sure that results pages in that section get boosted to the top (if you are searching from that section)
Oh. I see. Then I think you might need do a manual sort after the search.
Otherwise it may work by being a little creative with your query, but I haven't actually tested that. Eg. by searching for one field that will always be matched (could be nodeTypeAliasor some other field) along with the section using the OR operator (nodeTypeAlias:SubPage OR section:general^2).
I had similar thing ages ago for a law firm. So it was a listing page powered by search. Initially it was alphabetically ordered however partners wanted to be first in results.
So using Document writing if current employee type being indexed was partner they were boosted. Thus as search time on that page they were always top of the list. Although in your case this wont really work as you have a section variable which is not constant.
You could however use gathering node and during indexing for the subpage type get its parent and extract its id and inject that in as a separate field. Then during searching you know the section which you are passing in then you can boost on that field?
Thanks Ismail, yeah I'm already adding it to the index during gathering node, just need to figure out how to build the query.... so it doesn't' search for the section but just boosts the main result based on the current section
I'm not sure if this would help, but we did something kind of similar recently.
We had to introduce a "Featured Post" type of thing that would rank higher but we don't actually search for "Featured Post" being set.
So we ended up with something like this in our Lucene query:
(featured:(+1)^10 OR featured:(+0))
So effectively we search for both featured and not featured but boost the result for featured.
Thanks Nik, yeah not sure that scenario is useful since I need to boost depending on the current site section, not a property that all pages have... think that I'll have to manually sort after the search to accomplish what I want (like Anders mentioned)
Topic author was deleted
Examine/Lucene boosting relative to current site section
Hi all,
I'm implementing a search on a site using examine and have the following requirement.
Let's say the site structure is as follows
So if I search for bacon I get 2 results which is good! But how can I make it possible that depending on which section of the site you are on the result of that section is shown first in the results?
Currently I'm adding the section name to the index (in a new field called section) and also passing that to the search page ?q=bacon§ion=general
Of course if I add an or to the query Or().Field("section", sectionValue); I get all pages that are under that section.... and not only the pages that contain the word bacon
So I need a way of boosting without actually searching for the section term...
How would you accomplish that? All help appreciated!
Cheers, Tim
I'm only used to writing the raw queries, so you can write something like
section:general^2
(the^2
is the boost).If using the chained method approach as in your example, I believe there is a Boost() method as well. Eg. something like
Or().Field("section", sectionValue).Boost(2)
.Comment author was deleted
Thanks but the main issue I want to sort is that I don't want to search for the section just boost the main result if it's in that section, not sure if that's possible :)
Since I don't want to return all pages of that section, I just want to make sure that results pages in that section get boosted to the top (if you are searching from that section)
Oh. I see. Then I think you might need do a manual sort after the search.
Otherwise it may work by being a little creative with your query, but I haven't actually tested that. Eg. by searching for one field that will always be matched (could be
nodeTypeAlias
or some other field) along with the section using the OR operator(nodeTypeAlias:SubPage OR section:general^2)
.Comment author was deleted
Ok thanks for the tip :)
Comment author was deleted
So as an example:
if I search for bacon and I'm in section 1 I want to have
Subpage from section 1 containing bacon
Subpage from section 2 containing bacon
as results
If I search from section 2 I want
Subpage from section 2 containing bacon
Subpage from section 1 containing bacon
as results
And I don't want to include all subpages that are under the section in the search results
Tim,
I had similar thing ages ago for a law firm. So it was a listing page powered by search. Initially it was alphabetically ordered however partners wanted to be first in results.
So using Document writing if current employee type being indexed was partner they were boosted. Thus as search time on that page they were always top of the list. Although in your case this wont really work as you have a section variable which is not constant.
You could however use gathering node and during indexing for the subpage type get its parent and extract its id and inject that in as a separate field. Then during searching you know the section which you are passing in then you can boost on that field?
Regards
Ismail
Comment author was deleted
Thanks Ismail, yeah I'm already adding it to the index during gathering node, just need to figure out how to build the query.... so it doesn't' search for the section but just boosts the main result based on the current section
Hi Tim,
I'm not sure if this would help, but we did something kind of similar recently. We had to introduce a "Featured Post" type of thing that would rank higher but we don't actually search for "Featured Post" being set.
So we ended up with something like this in our Lucene query:
(featured:(+1)^10 OR featured:(+0))
So effectively we search for both featured and not featured but boost the result for featured.
Comment author was deleted
Thanks Nik, yeah not sure that scenario is useful since I need to boost depending on the current site section, not a property that all pages have... think that I'll have to manually sort after the search to accomplish what I want (like Anders mentioned)
is working on a reply...