Pnpjs: Changing Search context

Created on 18 Apr 2019  路  3Comments  路  Source: pnp/pnpjs

Category

  • [ ] Enhancement
  • [ ] Bug
  • [X] Question
  • [ ] Documentation gap/issue

Version

Please specify what version of the library you are using: [1.3.2]

Please specify what version(s) of SharePoint you are targeting: [Modern SPO]

Expected / Desired Behavior / Question

I'd like to change the context of the Search object but it seems that instantiating it as const search = new Search(absoluteURL) isn't making any difference in the results of the query. Am I doing something wrong or is this just possible?

sample answered question

All 3 comments

Hi @jcosta33,

Actually, new Search(webAbsUrl) ends up sending requests to provided webAbsUrl.

const search = new Search(webAbsUrl);
search.execute('*').then(console.log).catch(console.log);

however, you probably searching for a way to limit search with a specific web, then this is what you probably need:

search.execute(`* Path:${webAbsUrl}`).then(console.log).catch(console.log);

I think that was it, thanks!

Cool. Closing the issue.

Was this page helpful?
0 / 5 - 0 ratings