I did what this page teaches:
http://code.msdn.microsoft.com/SharePoint-2013-Querying-a629b53b
It works, but the thing is that I used the same KQL query in a content search webpart and I have something missing. I changed a bit the code to get me all site collections. I have 5 sites, two are projects web templates. The content search web part gives me all my sites, but the project ones are missing from my code!
Here's my query:
"contentclass:STS_Site -Path:http://mysite.server.com -Path:http://portal.server.com"
The query gives me all sites from my others webapps, like intranet.server.com, etc.
Comments are appreciated!
Just a few more info:
My Code:
var ctx;
var web;
var results;
function test() {
var queryStr = "contentclass:STS_Site -Path:http://mysite.ubi.com -Path:http://portal.ubi.com"
ctx = new SP.ClientContext.get_current();
var keywordQuery = new Microsoft.SharePoint.Client.Search.Query.KeywordQuery(ctx);
keywordQuery.set_queryText(queryStr);
var searchExecutor = new Microsoft.SharePoint.Client.Search.Query.SearchExecutor(ctx);
results = searchExecutor.executeQuery(keywordQuery);
ctx.executeQueryAsync(onQuerySuccess, onQueryFail);
}
function onQuerySuccess() {
$("#searchResults").append('<table>');
$.each(results.m_value.ResultTables[0].ResultRows, function () {
$("#searchResults").append('<tr>');
$("#searchResults").append('<td>' + this.Title + '</td>');
$("#searchResults").append('<td>' + this.Author + '</td>');
$("#searchResults").append('<td>' + this.Write + '</td>');
$("#searchResults").append('<td>' + this.Path + '</td>');
$("#searchResults").append('</tr>');
});
$("#searchResults").append('</table>');
}
function onQueryFail(sender, args) {
alert('Query failed. Error:' + args.get_message());
}
$(document).ready(function () {
$("#btn").click(function (e) {
e.preventDefault();
test();
});
});
PS.: I did a full crawl and nothing changed. Well, it worked for the document center, but not for the project sites (PROJECTSITE#0) PS2.: I also checked if fiddler to make sure it wasn't the code, but the response is really different in each of the cases.