Problem/Motivation

As far as I can see the vectorSimilarity Query does not work.

If you want to use a vectorSimilarity Query the query parser needs to be introduced like this to Solr:
?q={!vectorSimilarity f=vector minReturn=0.7}[1.0, 2.0, 3.0, 4.0]

The module now is always using the knn Query Parser (k-nearest) like this:
?q={!knn f=vector topK=10 minReturn=0.7}[1.0, 2.0, 3.0, 4.0]
It adds the "minReturn" parameter, but this will not be handled together with knn Query Parser.

Imho on the Solr side it is either "knn Query Parser" or "vectorSimilarity Query parser", but no combination is possible.

The module should probably account for this. So the settings would probably need to be provided/collected different. One needs to chose the query parser and depending on this either "topK" or "minReturn" (and "minTraverse") can be set.

Then the query should use corresponding query parser and parameters.

Steps to reproduce

Enter a value for "Minimum return" in configuration and see that results with similarity below this value will still be shown.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

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

stefan.korn created an issue. See original summary.

stefan.korn’s picture

Providing MR as a proposal to solve this. Should basically enable to have either a "knn" query or a "vectorSimilarity" query and have the proper parameters applied.

There surely is way to optimize this. Following comes in mind:

- define the query parser options centrally, maybe with info about parameters
- whether or not to integrate the knn_text_to_vector Query Parser. This requires some special solr configuration (solr loaded model). But if someone has this, maybe the option to use it would be nice
- parameters and default. Use solr defaults instead of custom defaults. For example topK parameter defaults to 10 in Solr and topK is optional. So we could maybe leave topK empty by default and if topK is empty just not add to solr query which results in 10. If a value is specified for topK, provide this.

btw: #3550744: When selecting a new plugin, old config values are loaded in for for top_k and minimum_return is in some way related to this, though there is no solution for #3550744 here. But the MR introduces FormAPI states to show and hide relevant configuration options, which might be a way to solve #3550744 differently. I had a look into the Ajax callback and it seems difficult to unset the values in the Ajax callback.