It looks like GetContentByTag only takes one tag unfortunately so it will be looking for one tag called "Test,Test 2" and failing.
I've been using Examine to search by tags - if you add the tag property to your settings to make sure it is indexed then you can just run a search on that field.
Otherwise I guess you could run your old query and then inflate the IPublishedContent from the ids? Not ideal but I guess it's okay if you don't have a lot of content.
So normally I do a wee Examine event to replace any commas with spaces and lowercase the tag name and use this field to search on (so there's no need to add the field to examineIndex in this case). I've included an example of a simple search class.
Get content by multiple tags not returning any results
Hi all,
I'm trying to get content by multiple tags using Umbraco.TagQuery.
If I pass in the 1 tag as below, it returns a result set.
But if I try to search by a comma seperated string it returns nothing:
Also, if I use the old method, everything works as intended:
Am I doing something wrong here? Is this the best way to get content by tags?
Thanks in advance,
Kev
It looks like GetContentByTag only takes one tag unfortunately so it will be looking for one tag called "Test,Test 2" and failing.
I've been using Examine to search by tags - if you add the tag property to your settings to make sure it is indexed then you can just run a search on that field.
Otherwise I guess you could run your old query and then inflate the IPublishedContent from the ids? Not ideal but I guess it's okay if you don't have a lot of content.
Aha. Using Examine sounds like a really good idea actually.
Would you be able to show me an example by any chance?
Thanks Valerie
HI,
So normally I do a wee Examine event to replace any commas with spaces and lowercase the tag name and use this field to search on (so there's no need to add the field to examineIndex in this case). I've included an example of a simple search class.
https://gist.github.com/anonymous/9955a1ee2b4cdef76cc0
Valerie
Brilliant, thanks Valerie. I'll see if I can implement something along those lines :)
is working on a reply...