Closed frread closed 7 months ago
Usually, the best approach is to check the network tab after running the same call in PnPjs and see what the call looks like. If there's a difference you can point to then that would help track down how to fix it either with something you're doing or something wrong in the library.
i checked the network and the querytext is the same,
here is the request url and the payload
url: https://
{"request":{"Querytext":"isDocument:True AND siteId: '<site-id>' AND (PATH:*Han*)","SelectProperties":["Title,FileExtension,LinkingUrl,FileType,UniqueId,Author,Created,LastModifiedTime],"SortList":[{"Property":"LastModifiedTime","Direction":1}],"RowLimit":10,"HitHighlightedProperties":[],"Properties":[],"RefinementFilters":[],"ReorderingRules":[]}}
what i am triying to achieve is a text search of the path so if i look for example "Han" i am able to bring the drive-items for that site, where "Han" appears anywhere on the path, either the folder structure or the item name
The example you shared has a URL of https://.sharepoint.com/sites//_api/search/postquery
which is for SharePoint search not Graph search, those are two entirely different endpoints and work differently. Do you mean to use Graph search instead?
i wanted to use sharepoint, but i was testing in graph explorer did not know they where different. Any ideas how i can do this search using the sharepoint end point?
That's a big question. You need to understand what ManagedProperties are available to get the values you want to filter and then use KQL to create the filter. I can guess that you're probably going to want to query on ContentTypeId which is a managed property, you can do a contains with the root content type id for a document which is 0×0101
. After that you'll have to do some research for which managed properties you need. I would start in the SharePoint Admin center, under Search configuration.
i know the path property is there, and the url, the issue would be why it is not being filtered.. Thank you for your help let me keep reseraching to see what i can find
Agree with Julie, learning KQL for the SharePoint API would help a bit here, as they do behave differently. If you look at the link she sent, you'll find the docs about prefix matching.
Your wildcard is wrong. You can't prepend to the term. Prefix matching only works at the end of the word, not the beginning so your search is invalid. So `Han*` is not a valid wildcard specification.
after understanding that there are 2 different endpoint for graph and sharepoint i was able to find the managed property to use for my search in sharepoint. For graph i could use the path property but in sharepoint this one does not work, i had to use the ItemPath
I'm going to close this issue as answered. If you have further issues, please feel free to create a new issue and reference this one.
This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.
Major Version
3.x
Minor Version Number
20
Target environment
SharePoint Framework
Additional environment details
spfx webpart development to use in sharepoing online
Expected or Desired Behavior
i would expect both queries in the graph explorer and in the sp.search would bring the same results
Observed Behavior
i am getting empty response
Steps to Reproduce
I run the following search query in graph explorer
where is the current site-id where the fxpart is deployed and the results is what i expected.
But when i run this in my spfx
the results come as 0 and nothing is brougth.
If have tested my code in many ways and only when i put the PATH search parameter do the results differ Why could this be happening?