question

SamuelLvesque-9233 avatar image
0 Votes"
SamuelLvesque-9233 asked SamuelLvesque-9233 commented

Graph search in SPO page query result truncated

Hi,

I'm doing the following query on a SharePoint site to retrieve latest news :

POST v1.0 https://graph.microsoft.com/v1.0/search/query

Body
{
"requests": [
{
"entityTypes": [
"listItem"
],
"query": {
"queryString": "PromotedState=2 AND path:\"https://tenant.sharepoint.com/SitePages*\""
},
"from": 0,
"size": 5,
"sortProperties": [
{
"name": "FirstPublishedDate",
"isDescending": true
}
]
}
]
}


The value I want to retrieve is the auto generated content in the field "summary" 124757-summary.png





Results :

{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.searchResponse)",
"value": [
{
"searchTerms": [],
"hitsContainers": [
{
"total": 4,
"moreResultsAvailable": false,
"hits": [
{
"hitId": "DA08628F-692D-4B2C-B4A3-3C2219EC4BCC",
"rank": 1,
"summary": "Comment effectuer la prise en main ? Sélectionnez « Modifier » pour commencer à utiliser ce modèle de base de deux colonnes et mettre l'accent sur le texte et les exemples de la<ddd/>",
"resource": {
"@odata.type": "#microsoft.graph.listItem",
"fields": {
"title": "TEST1234",
"firstPublishedDate": "2021-04-22T17:43:09Z"
}


As you can see the Summary field appears to be truncated after 170 characters instead of the 255 characters available :

Result from the query :
Comment effectuer la prise en main ? Sélectionnez « Modifier » pour commencer à utiliser ce modèle de base de deux colonnes et mettre l'accent sur le texte et les exemples de la<ddd/>

Value stored in the field from SPO:
Comment effectuer la prise en main ? Sélectionnez « Modifier » pour commencer à utiliser ce modèle de base de deux colonnes et mettre l'accent sur le texte et les exemples de la mise en forme du texte. Avec votre page en mode d’édition, sélectionnez…


Any idea how to return the full string ?

Regards

microsoft-graph-search
summary.png (31.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Sebastien-Levert-MSFT avatar image
0 Votes"
Sebastien-Levert-MSFT answered SamuelLvesque-9233 commented

Hey @SamuelLvesque-9233!

You should select the fields you need. In this case, the summary field is truncated by default and only focuses on the main part of the description. This could also be from the content of the page in some scenarios. To ensure you are getting back the Description field from search, please include the "description" field in the retrieved fields, like this :

 {
     "requests": [
         {
             "entityTypes": [
                 "listItem"
             ],
             "query": {
                 "queryString": "PromotedState=2 AND path:\"https://tenant.sharepoint.com/SitePages*\""
             },
             "fields": [
                 "id",
                 "name",
                 "contentclass",
                 "title",
                 "description"
             ]
         }
     ]
 }

Hope this works for you!

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you! It is working sucessfully using the Description field!

1 Vote 1 ·