-
-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ordering Results in Sharepoint Search #496
Comments
@vgrem this is not been implemented yet, correct? |
Greetings @domdinicola and good to hear from you :) For the it could be represented like this: ctx = ClientContext(site_url).with_credentials(credentials)
search = SearchService(ctx)
request = SearchRequest("sharepoint", sortlist="rank:descending,modifiedby:ascending")
result = search.query(request).execute_query() For request = SearchRequest(query_text="sharepoint",
SortList={'results': [
{
'Direction': 1,
'Property': 'ModifiedBy',
},
{
'Property': 'Created',
'Direction': '0'
},
]})
result = search.post_query(request).execute_query() In terms of API design and usability apparently not the most intuitive and will be improved in future releases. |
Greetings to you @vgrem ! Always good to hear from you :) This doesn't seem to work for me... I also tried with different Property/Fields and changing the Direction... |
Hi @domdinicola, hmm, seems to be working as expected on my side. Anyway in a new version (
search = SearchService(ctx)
result = search.query("IsDocument:1").execute_query()
search = SearchService(ctx)
request = SearchRequest(query_text="IsDocument:1",
sort_list=[Sort("LastModifiedTime", 1)],
select_properties=["Path", "LastModifiedTime"],
row_limit=20) Sorting search results examplerequest = SearchRequest(query_text="IsDocument:1",
sort_list=[Sort("LastModifiedTime", 1)],
select_properties=["Path", "LastModifiedTime"],
row_limit=20)
result = search.post_query(request).execute_query()
relevant_results = result.value.PrimaryQueryResult.RelevantResults
for r in relevant_results.get('Table').get('Rows').items():
cells = r[1].get('Cells')
print(cells[1].get('Value')) Result |
hi @vgrem ! Thanks for your help here! Much appreciated :) Dom |
Greetings @domdinicola, ah, good catch, thanks! I confirm it is not explicitly exposed in 2.3.12 but it should be backward compatible and therefore request = SearchRequest(query_text="IsDocument:1",
sort_list=[Sort("LastModifiedTime", 1)],
select_properties=["Path", "LastModifiedTime"],
row_limit=20, SourceId="--source id goes here--") |
Thanks @vgrem , Best, |
Hi @vgrem ,
Was wondering if the ordering is implemented in the Search Functionality..
I saw https://docs.microsoft.com/en-us/sharepoint/dev/general-development/sharepoint-search-rest-api-overview#sortlist , not sure if it's implemented
The text was updated successfully, but these errors were encountered: