Querying images with tags that contains dashes/hyphens

Comments

4 comments

  • Avatar
    Loic Verger Del Bove

    Hi Leanne,

    I have tested the dash on my side and I am able to get some results, here is my code snippet in NodeJS:

    cloudinary.search.expression('tags:test-tag').with_field('tags').execute().then(result=>console.log(result));

    However, this request will also return results for images tagged with either `test` or `tag`, to avoid that, you can add a `*` after the tag itself like this:

    cloudinary.search.expression('tags:test-tag*').with_field('tags').execute().then(result=>console.log(result));

    In case it is still not working for you, may I ask you to share an example URL of an image with the tag `macatawa-ballroom`?

    Hope it helps.

    Best,

    Loic

    0
    Comment actions Permalink
  • Avatar
    Leanne Stoll

    Hi Loic,

     

    I'm experiencing two issues.

    1) I've tried your approach and it does work, however if I use the star (*) symbol at the end of a tag with a dash in it, the Search API interprets it as a wildcard symbol, and matches any tags that start with "macatawa-ballroom". There could be cases where the wildcard might match with tags that we don't intend to match with, if both tags start with "macatawa-ballroom".

    Is there anyway to create a search query that matches exactly "macatawa-ballroom", or any other tags that have dashes in them?

     

    2) Another issue I found is that if an image has a tag with a dash, like "macatawa-ballroom", and if I search for a tag "macatawa", I'd expect an image with the "macatawa-ballroom" tag to not get returned, however it does get returned in the response.

    Is there a way to exclude tags with dashes from the search results in this scenario, where the tag I'm searching for is a subset of the tag with a dash in it? In this scenario, I'm trying to get an exact "macatawa" tag match.

     

    Thanks

    0
    Comment actions Permalink
  • Avatar
    Adabel Berdina

    I was also looking for this code and great it is here.

    0
    Comment actions Permalink
  • Avatar
    Loic Verger Del Bove

    Hi Leanne,

    Could you try using `=` instead of `:` for exact matches:

    cloudinary.search.expression('tags=test-tag').with_field('tags').execute().then(result=>console.log(result));

    Hope it helps.

    Best,

    Loic

    0
    Comment actions Permalink

Please sign in to leave a comment.