1
votes

I have used Sitecore fast query in my C# code to get items and sub items which are matching with the criteria. But fast query does not returning any items though there are.

My fast query is like below; fast:/sitecore/content/...//*[@__Workflow state='{item id}']

This will return no items, but removing fast: from the query will return the items by taking more time.

I tried escaping spaces in the query path as well like below, but it didn't work; fast:/sitecore/content/...//*[@#__Workflow state#='{item id}']

Are there any way to get sub items with a filtration using fast query?

1
Be careful using fast query in your front-end. In my experience, fast query always hit the database, even when the Item cache was built. I found that replacing fast query with regular queries through the tree such Sitecore.Context.Item.GetChildren() all the way through was much faster because after it performed the query once, the following times it ran was against the Item cache while the same query usimg fast always hit the database, regardless of Item cache.DougCouto

1 Answers

0
votes

I noticed you use theee dots in your query, which is not correct. You can use 2 dots to sleect the parent item, but in your query selecting the parent from /sitecore/content seems a bit odd.

It seems you can do with this query:

fast:/sitecore/content//*[@__Workflow state='{item id}']

See also this document for the syntax and examples and the limitations of using fast-query instead normal query

EDIT:

Sitecore Fast query does not account for the context language (results include items with versions that match the query in any language). I just did a quick test in the Developer Center in Sitecore and in my case it only resulted an item with the workflow state set in the english language, not my current context language. This might be something that you experience in your situation.