The rest query is as follows, I want to get most viewed pages. I have used ViewsLifeTime property. This query returns some pages (unwanted) which their ViewsLifeTime is null.

https://domain.com/_api/search/query?querytext='ContentTypeId:0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39*'&sortlist='ViewsLifeTime:descending'&filter=ViewsLifeTime gt '0'

I have tested with eq, ne as well.

The ViewsLifeTime of unwanted pages is like:

<d:element m:type="SP.KeyValue">
  <d:Value m:null="true"/>

But I want to have those pages is viewed (ViewsLifeTime is not null) like:

 <d:element m:type="SP.KeyValue">

The other problem with this query is it returns all pages within the farm. I want to get pages only from current Site collection.

How do I filter out those pages that have not been viewed (ViewsLifeTime is null) and restrict the result to current Site Collection?


I don't think the $filter parameter works on the search API. You need to specify the filters in the querytext parameter.


As for the specific to site collection. There is a WebID property for the querytext, not sure about Site Collection.

What I do is test my querytext in the standard SharePoint search box to get my query string value for my api calls!

  • Try level=sitecol for site collection only – SteveCl Dec 3 '13 at 13:58

First enable Search and Query property for "ViewsLifeTime" managed property in search service and perform full crawl.

Use Search Query API for not returning the items for which "ViewsLifeTime" count is null


Reference Links :- Filter for Empty Values in Search

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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