Examine - Document Level Boost Changes
# help-with-other
n
Hi All, I'm trying to replicate some code from a v8 site into a v13 site. In the v8 site, there was a hook into the document writing event to apply a document level boost based on various factors. In v13, I'm able to get to the same event without an issue, however Document no longer contains a "Boost" property. The Lucene docs say this:
Copy code
text
If you previously used the setter of Document.Boost, you must now pre-multiply the document boost into each Field.Boost. If you have a multi-valued field, you should do this only for the first Field instance (ie, subsequent Field instance sharing the same field name should only include their per-field boost and not the document level boost) as the boost for multi-valued field instances are multiplied together by Lucene.
My problem is, I don't understand what it's saying or how I should modify the code so that things are "boosted" correctly - does anyone have any pointers?
j
The way to go is to move the boost onto the search query it seems: https://github.com/Shazwazza/Examine/issues/331
n
Unfortunately, I can't see how this logic that I'm working with can be applied at "search" time as opposed to query time. High level of what it was doing previously: 1. boost multiplier starts at 1f. 2. if the document being indxed/writtern is flagged as archived, reduce multiplier ( / 1000) 3. if the document being indxed is flagged as external, reduce multiplier ( / 5000) 4. if the document is a specific page type (myPageAlias) then: 4.1 if has tag value of A - set boost value to AV * multiplier 4.2 if has tag value of B - set boost value to BV * multiplier ... (5 other conditions following same practice. 5. set document boost to boostValue if any one of those conditions has passed. As you can see the boosting is based on values on the page being indexed currently and I just cannot fathom how to change that to be on the search term itself - I also can't seem to figure out how to a boost on a field at index time. I just can't seem to get my head around the docs on it.
j
I agree that boosting on index time feels nicer, but seems to not be the recommended approach anymore. Adding the same boosting logic to your search queries should have the same effect though, so probably something like this:
Copy code
csharp
query.And().GroupedOr(["archived"], "true".Boost(1 / 1000f), "false");
6 Views