Replies: 1 comment
-
In case this is useful to anyone, I've found that the query_template is recognised when using delegated permissions, but not with application permissions. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all.
I've been using the search endpoint in the python SDK and getting the expected results when setting the query_string. However I would like to limit the results to include only files from a single folder. This works in the graph explorer by setting the queryTemplate searchTerms path parameter (https://developer.microsoft.com/en-us/graph/graph-explorer), which helpfully provides the below code snippet to use in python.
However, with the python SDK, results are returned from every folder, not that specified in the query_template path (I have also tried the documentLink parameter with /* at the end of the path as suggested in the docs). Even if I put CreatedBy:Bob in the query_template, which should return no results, I get the same response as having not set the query_template at all. Is there anything else I need to do for the query_template to be respected?
In the QueryPostResponse object, I can see search_terms=['query string'] returned as expected (at the end of the object), but result_templates=None - should this contain the query_template?
Other information:
Many thanks for your help!
Code snippet from graph explorer (with site masked):
from msgraph import GraphServiceClient
from msgraph.generated.search.query.query_post_request_body import QueryPostRequestBody
from msgraph.generated.models.search_request import SearchRequest
from msgraph.generated.models.entity_type import EntityType
from msgraph.generated.models.search_query import SearchQuery
graph_client = GraphServiceClient(credentials, scopes)
request_body = QueryPostRequestBody(
requests = [
SearchRequest(
entity_types = [
EntityType.DriveItem,
],
query = SearchQuery(
query_string = "query string xyz",
query_template = "{searchTerms} path:https://site/personal/xxxx/Documents/xxx/xxx/",
),
),
],
)
result = await graph_client.search.query.post(request_body)
Beta Was this translation helpful? Give feedback.
All reactions