I have custom list with multi-select managed metadata column. How could I count the number of items (preferably using rest api), which has particular metadata in this column?

For example on my list there are items like below:

Item1: keyword1, keyword2
Item2: keyword1, keyword4
Item3: keyword3

And now, if I search for "keyword1", I should get value 2 (because 2 items have this metadata). If I search for "keyword4", I should get value 1.

  • 2
    Do you want to count number of keywords in metadata column or number of items in a list? Jun 9, 2017 at 14:02
  • Number of items in a list, which contains particular metadata.
    – pilime
    Jun 9, 2017 at 14:18
  • If you only need to get the number of items, a simple approach for that would be just to create a new view, where you filter the [Multi-select managed metadata column] = particular metadata. Then you can get the number of items by enabling the Totals to the view.
    – moe
    Jun 9, 2017 at 14:51
  • @moe problem is that my "particular metadata" is dynamic.
    – pilime
    Jun 9, 2017 at 14:56

1 Answer 1


Here is a syntax to get the count from the search results as we don`t have a way to query to get the total count.

siteurl/_api/search/query?querytext='(owstaxId<<metadata field name>>:"<<keyword>>") (IsDocument:True) Path:"<<library path>>" ListID:"library guid"'&selectproperties='Title'&startrow=0&rowlimit=10&trimduplicates=false

The example as follows

https://tenant.sahrepoint.com/_api/search/query?querytext='(owstaxIdMarket:"HP+Spring+2017") (IsDocument:True) Path:"https://tenant.sharepoint.com/Setup Sheets" ListID:"74df6ac9-6c26-4c17-a6b3-60756cdae097"'&selectproperties='Title'&startrow=0&rowlimit=10&trimduplicates=false

Then you can get the "Total Rows" value from the response.

enter image description here


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.