Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-17369

FunctionQParser's $param derefrencing ignores flags: breaks two arg vectorSimilarity() function for BYTE fields when constant vec is param ref

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • main (10.0), 9.7
    • None
    • None

    Description

      A coworker of mine recently ran into a problem that I believe stems from the way FunctionQParser recursively parses param references.

      When it creates the subParser that it uses, it does not set it's current "flags" on that parser...

        protected ValueSource parseValueSource(int flags) throws SyntaxError {
      ...
          } else if (ch == '$') {
            sp.pos++;
            String param = sp.getId();
            String val = getParam(param);
      ...
              QParser subParser = subQuery(val, "func");
              if (subParser instanceof FunctionQParser) {
                ((FunctionQParser) subParser).setParseMultipleSources(true);
              }
              Query subQuery = subParser.getQuery();
      ...
      

      One practical problem this causes, that i've seen "in the wild", is in the 2 argument variant of the vectorSimilarity function, where the VectorEncoding of the first arg (the field name) is used to set a flag on the  FunctionQParser  when parsing the second arg (which may be a constant vector)

      So something like this works fine, for either FLOAT32 or BYTE fields...

      q={!func}vectorSimilarity(my_vec_field,[1,...,2,3])
      

      But using a param reference like this...

      q={!func}vectorSimilarity(my_vec_field,$raw_vec)
      raw_vec=[1,...,2,3]
      

      ... parses the raw_vec param as a ConstKnnFloatValueSource (the default) even if my_vec_field uses BYTE encoding.

      Attachments

        1. SOLR-17369.patch
          7 kB
          Chris M. Hostetter
        2. SOLR-17369-1.patch
          10 kB
          Chris M. Hostetter

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            hossman Chris M. Hostetter
            hossman Chris M. Hostetter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment