Search function returning approximate results?

AI-generated summary

A user, Canapin, reported that the search function on their forum is returning approximate results instead of exact matches. They used the example of searching for “passants in:title”, which used to return the topic “les passants” among the first results, but now displays results with words like “passe”, “pass”, “passage”, and “passion” before the exact string “passants”.

JammyDodger suggested using double quotes around the word to make it an exact search, which helped but still returned a result with no “passants” in the title.

Canapin found this puzzling, and tgxworld explained that in French, “passants” is reduced to the “pass” lexeme before searching against post contents.

Canapin questioned the usefulness of this reduction, while sam explained that the French implementation in Postgres is responsible for the reduction and that it can be configured, but more advanced dictionaries are complicated to set up.

Hi.

I was searching for this topic on my forum: les passants - Autour d'une roue - Monocycle.info

The topic’s title is “les passants”

Before, searching with “passants in:title” would return this topic among the first results.

But now, it displays approximate results:

Instead of “passants”, you’ll see “passe”, “pass”, “passage”, “passion”, some of these words before even the exact string “passants”…

I suppose this is a bug?

I’m afraid I don’t know enough about the Search to know if that’s on purpose or not, but you can add double quotes around a word to make it an exact search if that helps?

Eg. "passants"

Résultats de recherche pour « "passants" in:title » - Monocycle.info

1 Like

That sure helps, but the default behavior is puzzling.

For an unknown reason, when searching the exact string with double quotes, it also returns a result that has no “passants” in the title (but it has in the first post content):

1 Like

En français, passants est réduit au lexème pass avant que nous ne recherchions dans le contenu des publications.

Un lexème est une chaîne, tout comme un jeton, mais il a été normalisé de sorte que différentes formes du même mot soient rendues identiques.

4 Likes

I understand.

Are the lexemes language-related?

I don’t feel it makes much sense in French to reduce such a word to “pass”. :thinking: This is more confusing than helping considering there are a lot of words that begin with “pass” without being (directly or not) related to the verb “passer”.

But if we can target the exact string with double quotes instead, that will do :slight_smile:.

Also, what’s with the second result not having “passants” in the title despite using the double quotes on my last screenshot?

This stuff is configurable in Postgres, but the French implementation in Postgres is the thing reducing this all the way down:

discourse_development=# select to_tsvector('french', 'passants');
 to_tsvector
-------------
 'pass':1
(1 row)

discourse_development=# select to_tsvector('english', 'passants');
 to_tsvector
-------------
 'passant':1
(1 row)

There are more fancy dictionaries that can be used, but they are extremely complicated to configure.

3 Likes