I'm trying to get a list of items from Sitecore that match a custom tag field. This is from an external application so I need to use one of the APIs to do this.
I've tried using the Sitecore ItemService API like so:
https://{baseurl}/sitecore/api/ssc/item/search?Term=technology&fields=ItemName,ItemId,Tag&includeStandardTemplateFields=true
However it's not working as I'd hoped it would.
I also read this SSE post and I don't think all of the content in it is correct:
Use the ItemService to perform a content search - as the list of fields you send in the parameters are not the list of fields to search in but are instead the fields you want to return in the response.
This is documented here by Sitecore:
So my question is how do I get a list of items which match a specific tag?
I've also tried using the Facet Option like so:
https://{baseurl}/sitecore/api/ssc/item/search?Term=technology&fields=ItemName,ItemId,Tag&includeStandardTemplateFields=true&facet=Tag|{61F954E0-0B1E-431D-B79F-2EDFF6CAD7B6}
The above doesn't work for me because:
- I'm forced to enter a 'Term' as this is mandatory, I don't want this as I just want to get any items matching Tags.
- The search does not march partial terms, so isn't very useful even if I could pass a search term
- I can't seem to limit the search to just search a single field (Tag)
- A further complexity is that their may be more than one tag (Item ID) stored against an item and I suspect that the facet filter will only look for full matches, not partial matches.
I would just use the Solr API to do a search, but I don't think I can as Lucene is being used instead of Solr to my knowledge.
Any thoughts on the above would be very welcome.
UPDATE:
I had some kind assistance from Vlad on slack and it's possible to pass * as a search term like so:
https://mysite.com/sitecore/api/ssc/item/search?term=*&facet=_templatename|Article&fields=ItemName,ItemId,TemplateName&includeStandardTemplateFields=true&database=master
It also looks like there are some inconsistencies in the way the field filter works and the facets. Facets have to be lowercase and also require the '_' prefix for standard fields, where as the &fields= list doesn't. I'm still not able to filter on my custom field though or multiple ids.