Jump to content

Recommended Posts

Posted

Hi

Many of my image tags are hypehenated - which is currently causing problems finding them using the API.

For example - say I have an image with tags 'sport-1', using the example provided on the pw site but adding a hyphen to the tag:

// Find pages containing an image with at least tag: sport-1 // This will match "sport" but not "sports". $mypages = $pages->find("images.tags~=sport-1");

This doesn't return the page.

 $mypages = $pages->find("images.tags=sport-1");  does return the page.

But if the image has multiple tags 'sport-1 green' for example - you cannot use just the = operator to find the image

So - my question is, how do I find the image with tag 'sport-1' when the image I'm looking for has tags 'sport 1 green';

Many thanks

Nik

Posted

Thanks horst

Yes - that returns the page - but it also returns the page for  ->find("images.tags%=sport") and  ->find("images.tags%=port-1") - which in my case stops it being of any use. 

Kind regards

Nik


Hi Soma

$pages->find("images.tags~='sport-1'") doesn't return anything either.

Regards

Nik

Posted

Hi Horst and Soma

Is this something I should report as a bug? I can't see it mentioned that hyphens can't be used in tags.

Kind regards

Nik

Posted

I'm not seeing any problem with %=sport-1 as horst suggested. It finds all iamge that has the tag "sport-1"

Posted

Thanks Soma 

Agreed - that returns the pages.

But the same pages would be returned for  ->find("images.tags%=sport") and  ->find("images.tags%=port-1")

So I cannot be certain that the pages returned contain exactly the search term requested - only a 'like' search.

In my particular case this could mean pulling in the wrong logo for a company.

Currently I'm looking at telling a customer to not use hyphens - but it feels like the wrong answer.

Kind regards

Nik

Posted

I think problem is that with fulltext ~ and * mysql doesn't index words with hyphens, I think it splits it and since it's left with "1" it doesn't index 1 or words with less than 4 chars. So if you use ~=sport it will find your sport-1 cause it's only indexing "sport".

http://stackoverflow.com/questions/5192499/how-to-allow-fulltext-searching-with-hyphens-in-the-search-query

http://bugs.mysql.com/bug.php?id=2095

Using % will work but also search phrases so sport-1 would also find sport-12

For now maybe don't use hyphens.


After all Tags should be words not "word-word" see?

  • Like 2
Posted

Ahhh -  thanks Soma for shedding light on this. Not a bug at all - just the way things are.

I think perhaps the answer for me is to convert dashes to underscores in the API  - or simpler - to tell the customer not to use the hyphens.

Thanks so much

Kind regards

Nik

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...