0

I'm encountering this issue: calling the POST /v1.0/search/query Graph API, with the following body:

{
    "requests": [
        {
            "entityTypes": ["listItem"],
            "query": {"queryString": "*"},
            "from": 0,
            "size": 20,
            "fields": []
        }
    ]
}

I get the following response:

{
    "value": [
        {
            "searchTerms": [],
            "hitsContainers": [
                {
                    "hits": [// 20 list items]
                    "total": 66,
                    "moreResultsAvailable": true
                }
            ]
        }
    ]
}

The query matches 66 items in total and I get 20 elements for page 1 ("from":0).

Because we have other results to see, let's get items for page 2 ("from":20):

{
    "requests": [
        {
            "entityTypes": ["listItem"],
            "query": {"queryString": "*"},
            "from": 20,
            "size": 20,
            "fields": []
        }
    ]
}

Now in the response I get a different number of total items:

{
    "value": [
        {
            "searchTerms": [],
            "hitsContainers": [
                {
                    "hits": [// 20 list items]
                    "total": 55,  // why?! it must be the same for every page!
                    "moreResultsAvailable": true
                }
            ]
        }
    ]
}

Unlike what said in the documentation total should return the amount of items retrieved by the query, independently from pagination. I get 55 items also for page 3.

If I set a page of 100 items ("size":100), I get 55 items in total field, so I guess this is the correct total amount.

Nevertheless I always get total to 55 if I add a sortProperties field in my request, also for page 1:

{
    "requests": [
        {
            "entityTypes": ["listItem"],
            "query": {"queryString": "*"},
            "from": 0,
            "size": 20,
            "sortProperties": [
                {
                    "name": "Created",
                    "isDescending": true
                }
            ]
            "fields": []
        }
    ]
}

Do you have any idea of why I have this behaviour?

Thank you.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.