Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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:Key>ViewsLifeTime</d:Key>
  <d:Value m:null="true"/>
  <d:ValueType>Null</d:ValueType>
</d:element>

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

 <d:element m:type="SP.KeyValue">
   <d:Key>ViewsLifeTime</d:Key>
   <d:Value>14</d:Value>
   <d:ValueType>Edm.Int64</d:ValueType>
 </d:element>

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?

share|improve this question

1 Answer 1

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

querytext='ContentTypeId:0x010100C568*+AND+ViewsLifeTime>0'

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!

share|improve this answer
    
Try level=sitecol for site collection only –  SteveCl Dec 3 '13 at 13:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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