Uploaded image for project: 'DSpace'
  1. DSpace
  2. DS-3616

Controlled vocabulary search doesn't work when delimiter is used

    Details

    • Type: Bug
    • Status: Code Review Needed (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 6.0
    • Fix Version/s: None
    • Component/s: DSpace API
    • Labels:
    • Attachments:
      0
    • Comments:
      0
    • Documentation Status:
      In Description

      Description

      Considering the vocabulary:

       

      A::B
      A::B::C
      A::C
      

       

      If you do a search (via autosuggest or lookup) by B, the result will be:

      A::B
      A::B::C
      

       If you search for A::B, you will get no result. This means that even if you accept a suggestion/lookup, an immediate search of the recently filled field will yield no results.

       

      This is due the fact that the search is done by XPath, and it's constructed by the template:

       

      protected static String xpathTemplate = "//node[contains(translate(@label,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),'%s')]";
      

       

      It will replace "%s" with A::B, and nothing will match the "::B"

       

      The fix is simple:

      1. Split the string by the delimiter
      2. concatenate multiple xpathTemplate (so it will search nested nodes)

      Here's an example of the current behavior:

       

      //A::B
      String xpathExpression = "//node[contains(translate(@label,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),'a::b')"
      

       

      Here's the expected behavior:

      //A::B
      String xpathExpression = "//node[contains(translate(@label,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),'a')
      //node[contains(translate(@label,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),'b')
      "
      

       The expression will search for nodes that contain B and are childs of nodes that contain A.

       

       

      I have a fix in my environment. I'll create a PR when I get around to it.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              edusperoni Eduardo Speroni
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: