0

One of the ways to conduct search via ItemService's RESTful API is through a stored query, as per the docs:

You use this method to run (“execute”) a query that is stored in a Sitecore item (a “query definition item”.)

So where can I find this "query definition item?"

1 Answer 1

2

According to Sitecore documentation you can run query stored on an item using

/item/{id}/query

url. You must replace the {id} part with the item which stores the query, e.g.

/sitecore/api/ssc/item/110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9/query

You can add more parameters, e.g. pageSize, page, database, includeStandardTemplateFields, fields:

/sitecore/api/ssc/item/110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9/query?pageSize=10&page=5

Description for all of the can be found in the link above.

There is a Query Definition template which you should use to store your query. Just create an item using that template. You can find it in Sitecore with /sitecore/templates/System/Services/Item Service/Query/Query Definition path:

enter image description here

3
  • There it is, thank you! Though I noticed that the field type for the query definition item is a Single Line Text, I assume that we write query scripts the same? e.g. query:/sitecore/content/**
    – Lala
    Oct 3, 2019 at 15:35
  • Tbh I'm not sure. Test it and let us know :)
    – Marek Musielak
    Oct 3, 2019 at 18:01
  • Confirmed that "query:" is not needed for the Query field. Example below: /sitecore/content/Site/Home/News//*[@@templatename='News Page'] Jul 28, 2021 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.