Orckestra / C1-CMS-Foundation

C1 CMS Foundation - .NET based, open source and a bundle of joy!
https://c1.orckestra.com/
Other
252 stars 109 forks source link

Include Boost in Orckestra.Search.WebsiteSearch.SearchResultEntry.FieldValues #790

Open slacto opened 2 years ago

slacto commented 2 years ago

I'm working with the new Boost value in SearchDocumentBuilder and I have created a ISearchDocumentBuilderExtension to boost recently added pages. I would like to have the Boost value in my search result. Like in Orckestra.Search.WebsiteSearch.SearchResultEntry.FieldValues. Can you add Score before boost and the Boost value in all search packages? It will be easier to explain to the customer if they can see the scores.

napernik commented 2 years ago

Hi Søren

The original value of index-time Boost property isn't preserved by the Lucene, so you may have to add a custom field to return it. If you calculate it as a formula based on when the document was indexed and some field values, you can run the formula dynamically to show in the results.

When it comes to scoring, it might be possible to add. I'm currently on a sick leave, when I'm back I'll try to do some debugging to see if Scoring information is available and can be exposed.

napernik commented 2 years ago

While Boost is seemingly not preserved, returning score should be doable:

image

It will be easier to explain to the customer if they can see the scores.

In Lucene there's already an option to include "explanation" into the search results. It might be more useful than just showing Scope and Boost:

browseRequest.ShowExplanation = true;

gives me the following results:

image

{3.923689 = (MATCH) sum of:
  3.600704 = (MATCH) weight(label:test^2.0 in 20), product of:
    0.9208084 = queryWeight(label:test^2.0), product of:
      2 = boost
      3.910372 = idf(docFreq=10, maxDocs=202)
      0.1177392 = queryNorm
    3.910372 = (MATCH) fieldWeight(label:test in 20), product of:
      1 = tf(termFreq(label:test)=1)
      3.910372 = idf(docFreq=10, maxDocs=202)
      1 = fieldNorm(field=label, doc=20)
  0.3229849 = (MATCH) weight(fulltext:test in 20), product of:
    0.3900153 = queryWeight(fulltext:test), product of:
      3.312536 = idf(docFreq=19, maxDocs=202)
      0.1177392 = queryNorm
    0.8281339 = (MATCH) fieldWeight(fulltext:test in 20), product of:
      1 = tf(termFreq(fulltext:test)=1)
      3.312536 = idf(docFreq=19, maxDocs=202)
      0.25 = fieldNorm(field=fulltext, doc=20)
}

I think we can always return the Score, and calculate the Explanation when needed.

I'm not 100% sure if we will have it in the next release, you can try adapting the source code for the package, which is located here:

https://github.com/Orckestra/CMS-Packages-Search

slacto commented 2 years ago

Hi Dmitry

Thanks. I think Including the explanation on request is sufficient.

Can a new attribute ShowExplanation be part of WebsiteSearchQuery in https://github.com/Orckestra/CMS-Packages/blob/master/Orckestra.Search.WebsiteSearch/Orckestra.Search.WebsiteSearch/WebsiteSearchFacade.cs#L43? So I can request it like https://www.lpb.dk/SearchResults?q=pension https://www.lpb.dk/SearchResults?q=pension&explanation=true &explanation=true.

Med venlig hilsen

Søren Westh Larsen Principal Software Developer

ACTO ApS, Torveporten 2, 4. sal. 2500 Valby Følg os på http://www.acto.dk/ acto.dk - https://www.facebook.com/actoas/ Facebook - https://www.linkedin.com/company/acto-a-s/ LinkedIn

Fra: Dmitry Dzygin @.> Sendt: 22. februar 2022 13:53 Til: Orckestra/C1-CMS-Foundation @.> Cc: slacto @.>; Author @.> Emne: Re: [Orckestra/C1-CMS-Foundation] Include Boost in Orckestra.Search.WebsiteSearch.SearchResultEntry.FieldValues (Issue #790)

While Boost is seemingly not preserved, returning score should be doable:

https://user-images.githubusercontent.com/1391705/155130707-09f58f97-f646-47ff-bb02-841e854b4767.png

It will be easier to explain to the customer if they can see the scores.

In Lucene there's already an option to include "explanation" into the search results. It might be more useful than just showing Scope and Boost:

browseRequest.ShowExplanation = true;

gives me the following results:

https://user-images.githubusercontent.com/1391705/155134268-9be6db59-387d-4678-8441-007e857972e3.png

{3.923689 = (MATCH) sum of: 3.600704 = (MATCH) weight(label:test^2.0 in 20), product of: 0.9208084 = queryWeight(label:test^2.0), product of: 2 = boost 3.910372 = idf(docFreq=10, maxDocs=202) 0.1177392 = queryNorm 3.910372 = (MATCH) fieldWeight(label:test in 20), product of: 1 = tf(termFreq(label:test)=1) 3.910372 = idf(docFreq=10, maxDocs=202) 1 = fieldNorm(field=label, doc=20) 0.3229849 = (MATCH) weight(fulltext:test in 20), product of: 0.3900153 = queryWeight(fulltext:test), product of: 3.312536 = idf(docFreq=19, maxDocs=202) 0.1177392 = queryNorm 0.8281339 = (MATCH) fieldWeight(fulltext:test in 20), product of: 1 = tf(termFreq(fulltext:test)=1) 3.312536 = idf(docFreq=19, maxDocs=202) 0.25 = fieldNorm(field=fulltext, doc=20) }

I think we can always return the Score, and calculate the Explanation when needed.

I'm not 100% sure if we will have it in the next release, you can try adapting the source code for the package, which is located here:

https://github.com/Orckestra/CMS-Packages-Search

— Reply to this email directly, view it on GitHub https://github.com/Orckestra/C1-CMS-Foundation/issues/790#issuecomment-1047766703 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQZZVTDKKPLYQPJX5M2OZ3U4OBLLANCNFSM5JYWKUXA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AAQZZVS7PGAW4N4SXJMTWY3U4OBLLA5CNFSM5JYWKUXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHZZ2NLY.gif Message ID: @. @.> >

napernik commented 2 years ago

An update: Orckestra.Search.LuceneNET version 1.2.1 was published

https://github.com/Orckestra/CMS-Packages-Search/commit/81da1d2d27cf63ddc8a7d555ca10fa77248fdef1

napernik commented 2 years ago

Can a new attribute ShowExplanation be part of WebsiteSearchQuery in https://github.com/Orckestra/CMS-Packages/blob/master/Orckestra.Search.WebsiteSearch/Orckestra.Search.WebsiteSearch/WebsiteSearchFacade.cs#L43? So I can request it like https://www.lpb.dk/SearchResults?q=pension https://www.lpb.dk/SearchResults?q=pension&explanation=true &explanation=true.

@slacto If you make a PR for the Orckestra.Search.WebsiteSearch, we'll merge it. The conditions could be a) having a C1 console user logged in and b) "explanation=true" in request URL