Trying to optimize our boost settings I though it would be a good idea to display the Relevance in the search results view. But this constantly says "1" no matter how slightly related the result is (containing just one similar term out of 2 search terms).

I gather from the Meilisearch documentation

The _rankingScore is a numeric value between 0.0 and 1.0.

If I'm not mistaken the Search: Relevance field should consenquently produce a float number. Maybe I am mistaken, then please change the issue component to "Dokumentation" ;-)

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

hexabinaer created an issue. See original summary.

hexabinaer’s picture

Category: Support request » Bug report
Priority: Minor » Normal

Ah yes, I should have had a look at the Log before writing:

Deprecated function: Implicit conversion from float 0.75 to int loses precision in Drupal\Core\Template\TwigExtension->withoutFilter()

tgoeg made their first commit to this issue’s fork.

tgoeg’s picture

I am also trying to track down relevancy problems as my boosts don't seem to cause any difference (but I think that the API key I use - intentionally not the master key - has some permission problems).

Relevancy is also always 1, in my case (in the view display for anonymous users). However, I do not get these errors in the log.
Do you have any custom twig involved that's possible typecasting to int here?

Or maybe this is a bug and my relevance is always 1 indeed (which won't cause any typecasting errors :) ). Which makes me wonder, I'd definitely like to see different relevancy. Your output seems to imply there is some relevancy that's not 1, which puzzles me.

I don't think this module reports any relevancy at all, yet, however.

https://php-sdk.meilisearch.com/classes/Meilisearch-Contracts-SearchQuer... says it would be $showRankingScore.
I don't see any mention of this in the code, should be in some $meiliOptions I guess.

hexabinaer’s picture

Yes sorry, I might have been mislead. The conversion from float to integer is probably totally unrelated.

However, I am still puzzled why the relevancy is always "1", no matter what operator I set, e. g. "Contains any of these words" (parse mode for fulltext search is "Multiple words")

tgoeg’s picture

Meilisearch itself and the PHP SDK/API allow for providing effective relevancy. It's just that this very module does not yet implement this and I guess a relevancy of 1 is the default, then.

I tend to say we should transform this into a feature request?

hexabinaer’s picture

Category: Bug report » Feature request

Right so :-)

hexabinaer’s picture

Title: Does the Search: Relevance field give any relevant information? » Implement relevancy

deaom changed the visibility of the branch 3441489-does-the-search to hidden.

deaom’s picture

Version: 2.0.1 » 3.x-dev
Status: Active » Needs work

The Ranking Score option was added to search function, so it's always set to true (turned on). The search api relevancy field that is used in views and added as a display, was updated in meili to display the rankingScore returned from search. There is a simple test added that checks that relevancy is present as default and then changes when there are results. Those tests are passing.
For some reason the synonyms tests are now failing with the ranking score change, that is why the status is set to needs work and MR is placed in draft.

deaom’s picture

Status: Needs work » Needs review

Tests are passing which means relevancy is ready for review.

bcizej’s picture

Status: Needs review » Needs work
deaom’s picture

I have no idea what the issue with the test is as locally all the tests are passing. Leaving as needs work if somebody else has any idea.

deaom’s picture

Status: Needs work » Needs review

The tests are now passing, needed to make name and body fields searchable by changing their type from string to text. Ready for review.

hexabinaer’s picture

Awesome! Thanks for the progress, I'll review.

deaom’s picture

Test are failing on gitlab-ci after the new meili-php in added to branch. Issue #3540463: Add timeout to waitForTask() does seem to resolve the failing tests on gitlab-ci, after the #3540465: Do not expose $this->connection() is merged.
This is relevant to testing on gitlab-ci only.

  • bcizej committed 11c29029 on 3.x authored by deaom
    Issue #3441489 by deaom, tgoeg, bcizej, hexabinaer: Implement relevancy
    
bcizej’s picture

Status: Needs review » Fixed

Rebased and merged, thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.