I am trying to retrieve images using REST SEARCH API from multiple Picture Libraries distributed across sub-sites(sub-sites are all under a single site collection https://xyz/site/*) .I also need to include various filters, such as 'created by' along with specific call to the sub-site libraries. I am currently retrieving images from the whole site-collection and I not able to limit the call to sub-sites only.
2 Answers
If you want to display results in specific subsites (not all sites in site collection):
In the querytext, enter paths of subsites.
_api/search/query?querytext='path:https://xyz/sites/<subsite1> path:https://xyz/sites/<subsite2> path:https://xyz/sites/<subsite3>'
And you can also add other queries to the querttext to achieve your requirement.
For example, get all pictures created by 'Test' from subsite1 and subsite2.
_api/search/query?querytext='path:https://xyz/sites/<subsite1> path:https://xyz/sites/<subsite2> Author:Test ContentType=Image'
-
I seem to have issues passing filters that you have indicated into the URL. I seem to be getting all or nothing response. Could you please let me know why logical ANDs below are not working, and also what does the 'search term' stand for as the query breaks down without it. querytext='search term'&sourceid='38403c8c-3975-41a8-826e-717f2d41568a'&rowlimit=40&path:XXX/sites/XXXXX Commented Jan 21, 2019 at 20:03
-
So, the issue is that there is no way for me to limit query passed in URL to limit the search for a specific site. I tried it on different farms and the behaviour is the same, I always query the whole site regardless of "path" parameter. Commented Jan 21, 2019 at 22:28
-
Enter the "path:<url>" in the querytext, refer to the demo in my answer. querytext='path:xxx/sites/xxxx'&sourceid='38403c8c-3975-41a8-826e-717f2d41568a'&rowlimit=40 Commented Jan 23, 2019 at 1:28
You could try adding ContentType=Image path:https://xyz/site/* Author:Bob
to your query text.`