Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Pagination using Filet Extension#301

Answeredbyjamesfisher-geo
dipstef78 asked this question inQ&A
Discussion options

Hello.

I am using the filter extension to query my catalog and I was wondering how can I paginate the results.
I saw that including the limit properties limit the number of results, but I cannot find a way to decide which page I want to have.

Can anyone help me please?

Thank you in advance.

You must be logged in to vote

At the bottom of the filter result is alinks object. If there are more items in the search result that the limit number, there will be anext link. That will open the next page of results.numReturned andnumMatched show the number of items in the page and the total number of search results, respectively.

"links": [        {"rel":"next","type":"application/json","method":"GET","href":"http://<stac api>/search?token=<next page token>"        },        {"rel":"root","type":"application/json","href":"http://<stac api>/"        },        {"rel":"self","type":"app…

Replies: 2 comments 2 replies

Comment options

At the bottom of the filter result is alinks object. If there are more items in the search result that the limit number, there will be anext link. That will open the next page of results.numReturned andnumMatched show the number of items in the page and the total number of search results, respectively.

"links": [        {"rel":"next","type":"application/json","method":"GET","href":"http://<stac api>/search?token=<next page token>"        },        {"rel":"root","type":"application/json","href":"http://<stac api>/"        },        {"rel":"self","type":"application/json","href":"http://<stac api>/search"        }    ],"numReturned":10,"numMatched":2670
You must be logged in to vote
2 replies
@dipstef78
Comment options

Hello@jamesfisher-geo and thank you for the reply.
I tried that and I will show you the steps I followed.

At first I made a request:

URL:
https://localhost:8080/search

Data:

{    "filter-lang": "cql2-json",    "limit": 1,    "collections": [        "my_collection"    ],    "fields": {        "include": [            "properties"        ]    },    "filter": {                ---- CQL2 query ----           }}

and received the following response

{    "type": "FeatureCollection",    "features": [        {            --- Query result with item A   ---        }    ],    "links": [        {            "rel": "next",            "type": "application/json",            "method": "POST",            "href": "https://localhost:8080/search",            "body": {                "filter-lang": "cql2-json",                "page": 1,                "limit": 1,                "collections": [                    "my_collection"                ],                "fields": {                    "include": [                        "properties"                    ]                },                "filter": {                   -- My filter query ---                },                "token": "MTcyNjMwNTAxMTg2MixURVNUX1BBQ0tFVF85LGV1cF9wcm9kdWN0c190ZXN0"            }        },        {            "rel": "root",            "type": "application/json",            "href": "https://localhost:8080/"        },        {            "rel": "self",            "type": "application/json",            "href": "https://localhost:8080/search"        }    ],    "context": {        "returned": 1,        "limit": 1,        "matched": 10    }}

I tried to use the token as you suggested in a GET call but the result was not conclusive:

https://localhost:8080/search?token=MTcyNjMwNTAxMTg2MixURVNUX1BBQ0tFVF85LGV1cF9wcm9kdWN0c190ZXN0

{    "code": "ValidationError",    "description": "2 validation errors for Item\nbbox\n  wrong tuple length 0, expected 4 (type=value_error.tuple.length; actual_length=0; expected_length=4)\nbbox\n  wrong tuple length 0, expected 6 (type=value_error.tuple.length; actual_length=0; expected_length=6)"}

I suppose that this error come from the items cotained in another collection without bbox values.
That collection is not mine I there is nothing I can do about that.

So, I tried to use the token inside the request data:

URL:
https://localhost:8080/search

Data:

{    "filter-lang": "cql2-json",    "limit": 1,    "token": "MTcyNjMwNTAxMTg2MixURVNUX1BBQ0tFVF84LGV1cF9wcm9kdWN0c190ZXN0",    "collections": [        "my_collection"    ],    "fields": {        "include": [            "properties"        ]    },    "filter": {                ---- CQL2 query ----           }}

Which gave me the following response

{    "type": "FeatureCollection",    "features": [        {            --- Query result with item B---        }    ],    "links": [        {            "rel": "next",            "type": "application/json",            "method": "POST",            "href": "https://localhost:8080/search",            "body": {                "filter-lang": "cql2-json",                "page": 1,                "limit": 1,                "collections": [                    "my_collection"                ],                "fields": {                    "include": [                        "properties"                    ]                },                "filter": {                   -- My filter query ---                  },                "token": "MTcyNjMwNTAxMTg2MixURVNUX1BBQ0tFVF85LGV1cF9wcm9kdWN0c190ZXN0"            }        },        {            "rel": "root",            "type": "application/json",            "href": "https://localhost:8080/"        },        {            "rel": "self",            "type": "application/json",            "href": "https://localhost:8080/search"        }    ],    "context": {        "returned": 1,        "limit": 1,        "matched": 10    }}

The response contains another item compared to the first call, so it seemes to work fine, but if you look at the "next" session you will see that the token is the same as before, so I am not able to go forward.

Am I missing something?

And also, nother question: is there a way to jump directly to a specific page?

Thank you very much

S

@jamesfisher-geo
Comment options

I believe the tokens are being created properly. Can you confirm that the you are able to paginate through the items?

The two tokens you provided are just slightly different when I decode them from base 64.
1726305011862,TEST_PACKET_8,eup_products_test
1726305011862,TEST_PACKET_9,eup_products_test

The API functions do not support jumping to a specific page, or previous pagination. This is a limitation of thesearch after pagination method of Elasticsearch/Opensearch.

Answer selected bydipstef78
Comment options

Oh my god!
You are right! I probably made a mistake copy/pasting during the test and, since the tokens where very mimilar, I thought that it was the same everytime.
I confirm that I am able to paginate.

It is a shame that there is no way to jump to specific pages, but I will find a way.

Thank you very much.

S

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@dipstef78@jamesfisher-geo

[8]ページ先頭

©2009-2025 Movatter.jp