Good day, I have SP list. I must get this list items usage data for 2020 year. This is 2020 year statistics about list items viewing. I can show popularity trends on page by managed properties ViewsLastMonths1, ViewsLastMonths2, ViewsLastMonths3 https://tantumpoint.wordpress.com/2017/10/03/sharepoint-search-get-usage-data-from-search/ But how can I get information about views last 6 months or 12 months ? Is it possible to create managed property ViewsLastMonths6 or ViewsLastMonths12 ? My script
<script type="text/javascript">
$(document).ready(function () {
var titleLabel=[];
var titleView=[];
$.ajax({
url: "<MY SITE>/_api/search/query?querytext='Path:<MY SITE>/Lists/1/+ContentClass:STS_ListItem+ContentClass:STS_ListItem_DocumentLibrary'&selectproperties='Title,path,ViewsLifeTime,ViewsLastMonths3,ViewsLastMonths3Unique'&rowlimit=5000",
type: "GET",
headers: {
"Accept": "application/json;odata=verbose"
},
success: function(data) {
//log the json to analyze and visualize
var items=data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results;
//log the actual 10 items that is going to be displayed
//console.log(items);
var i=0;
var data = [];
$.each(items, function(index, item) {
var ret= items[index].Cells.results[6].Value;
var title = keyValue(this, 'Title');
var ViewsLastMonths3 = keyValue(this, 'ViewsLastMonths3');
var ViewsLastMonths3Unique = keyValue(this, 'ViewsLastMonths3Unique');
//replacing any spaces in the URL
var itemlinks= ret.replace(/ /g,"%20");
data.push({title: title, ViewsLastMonths3:ViewsLastMonths3, ViewsLastMonths3Unique:ViewsLastMonths3Unique, itemlinks:itemlinks});
});
// To show 10 most popular items last 3 Months
data.sort(function(a, b){
return b.ViewsLastMonths3-a.ViewsLastMonths3
})
$.each(data, function(i,v){
if (i<10){
titleLabel.push(v.title);
titleView.push(v.ViewsLastMonths3);
$('#popular tr:last').after('<tr><td><a target="_blank" class=itemtitle href='+v.itemlinks+'>'+v.title+'</a></td><td>'+ v.ViewsLastMonths3 +'</td><td>' + v.ViewsLastMonths3Unique + '</td></tr>');
i++;
}
});
}
});
function keyValue(row, fldName) {
var ret = null;
$.each(row.Cells.results, function () {
if (this.Key == fldName) {
ret = this.Value;
}
});
return ret;
}
});
</script>