Can anyone point me to an example or share some code on how to search multiple sites libraries with a single API Rest call? For example, I have a side called Document Archive and in that archive I have two document lists called Archive1 and Archive2. Here is the URL I am using to search:
https://example.com/TS/EDMS/_api/search/query?querytext='Tequila'&(path:https://example.com/TS/EDMS/GSSCDocs/)&rowlimit=33&trimduplicates=true
If I run this from a console application I get 33 rows every time. But if I cut and paste this url into my web browser, I get only 2 results. If I go right to the document library and do the same search I get the same 2 results. So for some reason the rest calls from my console app are generating more results. So I suspect it has to do with the Path: statement. So two questions:
- How can I add more paths to this list? If I want to add path https://example.com/TS/EDMS/Archive/ to the path can I do this, or do I need to make two separate calls?
- Why am I getting more results from my console application than when I do a site search or paste the url into my browser?
Here is the code I am using to post the string to the site:
HttpWebRequest endpointRequest = (HttpWebRequest)HttpWebRequest.Create(queryString);
endpointRequest.Method = "GET";
endpointRequest.Accept = "application/json; odata=verbose";
endpointRequest.UseDefaultCredentials = true;
HttpWebResponse endpointResponse = (HttpWebResponse)endpointRequest.GetResponse();
//var _searchResults = SearchResult2(endpointResponse);
Stream webStream = endpointResponse.GetResponseStream();
StreamReader responseReader = new StreamReader(webStream);
string response = responseReader.ReadToEnd();
JObject jobj = JObject.Parse(response);
var docReturnResult = new List<DocumentSearchResult>();
JValue rowCount = (JValue)jobj["d"]["query"]["PrimaryQueryResult"]["RelevantResults"]["RowCount"];
int loopCount = rowCount.ToObject<int>();
for (int i = 0; i <= loopCount - 1; i++)
{...process results here}