Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discovery - Search use cases/requirements gathering #390

Closed
ericdrosas87 opened this issue Feb 14, 2024 · 4 comments
Closed

Discovery - Search use cases/requirements gathering #390

ericdrosas87 opened this issue Feb 14, 2024 · 4 comments

Comments

@ericdrosas87
Copy link
Contributor

ericdrosas87 commented Feb 14, 2024

User story

As the maintainer of the DAM plugin, I need to gather requirements and use cases for the gallery enhancements so as to design the code workflow accordingly.

Definition of done

I have gathered all use cases and requirements to adequately write the code for the gallery enhancements.

@ericdrosas87
Copy link
Contributor Author

Let me know if I'm missing something here @blnkt , but I think the only use cases I'll be coding for are:

  1. Add whereContains directive
  • Accepts two required arguments:
    • A single field to search
    • The text to fuzzy match on
  • Returns all matches (a collection subset) from the gallery
  • Expected usage (not exact, depends on Craft entry structure):
{
  entry(section: "someGalleryPage") {
    ... on galleryItems_galleryItem_Entry {
      galleryField(whereContains: {key: "additional.CaptionEN", value: "bird"}) {
        id,
        url {
          directUrlOriginal
        }
      }
    }
  }
}
  1. Add whereContainsIn directive
  • Accepts two required arguments:
    • A collection of fields to search
    • The text to fuzzy match on
  • Returns all matches (a collection subset) from the gallery
  • Expected usage (not exact, depends on Craft entry structure):
{
  entry(section: "someGalleryPage") {
    ... on galleryItems_galleryItem_Entry {
      galleryField(whereContainsIn: {key: ["additional.CaptionEN", "additional.CaptionES"], value: "bird"}) {
        id,
        url {
          directUrlOriginal
        }
      }
    }
  }
}

@blnkt
Copy link
Contributor

blnkt commented Feb 15, 2024

@ericdrosas87

  1. For simplicity, you may just build whereContainsIn since its functionally is inclusive of whereContains's functionality (although whereContains as nice as a convenience method). Syntactically the first argument should probably be keys not key since it's expecting an array.
  2. Items should be returned in the collection of results if the value arg is a partial match on a key's value. So, for instance, (using your example) if value: "bird" and an item with a key:value pair "additional.CaptionEN": "A bunch of lovely birds", whereContainsIn would consider this a match and include this item in the collection of results.
  3. This method should return an item if any of the values of its keys are a partial match to the value arg. So, for instance, (using your example) if value: "bird" and an item with a key:value pairs "additional.CaptionEN": "A bunch of lovely dogs" and "additional.CaptionES": "A bunch of lovely birds", whereContainsIn would consider this a match and include this item in the collection of results.
  4. Punctuation should probably be stripped from value before it's used as a matching term. You tell me if I should have the client do that before the query is sent over, or if you want your method to do it on receipt.
  5. For this first iteration, we ought to target maximum fuzziness. And therefore, given value: "first second third fourth many", whereContainsIn should break apart value into substrings, splitting on whitespace (["first", "second", "third", "fourth", "many"]), and then look for partial matches of each keys' value to each of these substrings.

@ericdrosas87
Copy link
Contributor Author

  1. Punctuation should probably be stripped from value before it's used as a matching term. You tell me if I should have the client do that before the query is sent over, or if you want your method to do it on receipt.

Probably the client should do that, although if there is punctuation in the value in the DB and you strip the punctuation there will no longer be a fuzzy match

@ericdrosas87
Copy link
Contributor Author

Regarding lsst-epo/canto-dam-assets#4 (comment)

These issues should be resolved, I've tested with the following queries with a gallery field containing Web Elements/Investigations/Data - Exploding Stars/3V_images/images from Canto:

query MyQuery {
  galleryItemsEntries {
    ... on galleryItems_galleryItem_Entry {
      id
      cantoGallery(whereContainsIn: {keys: ["name", "smartTags"], value: "test Board"}) {
        url {
          directUrlOriginal
        }
      }
    }
  }
}

The above returns records with a fuzzy match on the smartTags key with the word Board.

query MyQuery {
  galleryItemsEntries {
    ... on galleryItems_galleryItem_Entry {
      id
      cantoGallery(whereContainsIn: {keys: ["smartTags", "name"], value: "test board"}) {
        url {
          directUrlOriginal
        }
      }
    }
  }
}

The above returns records with a fuzzy match on the smartTags key with the word board.

query MyQuery {
  galleryItemsEntries {
    ... on galleryItems_galleryItem_Entry {
      id
      cantoGallery(whereContainsIn: {keys: ["name"], value: "img"}) {
        url {
          directUrlOriginal
        }
      }
    }
  }
}

The above returns records with a fuzzy match on the name key with the word img.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants