Home > OS >  'Validation Failed: 1: [indices] cannot be used with point in time;'}]
'Validation Failed: 1: [indices] cannot be used with point in time;'}]

Time:04-13

Following this guide (https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html) I created a PIT ID and using the ID attempt to paginate search results using the query :

start_date = '2020-03-11T00:00:00Z'
end_date = '2021-10-30T00:00:00Z'

start_date = datetime.datetime.strptime(start_date, "%Y-%m-%dT%H:%M:%SZ")
end_date = datetime.datetime.strptime(end_date, "%Y-%m-%dT%H:%M:%SZ")

search_param = {
                "size": 10000,
                "query": {

                    "bool": {
                        "must": [
                            {"range": {"ts": {"gte": start_date, "lt": end_date}}}
                        ],
                        "should": [
                            {"exists": {"field": "data.test1"}},
                            {"exists": {"field": "data.test2"}},
                            {"exists": {"field": "data.test3"}}
                        ],
                        "minimum_should_match": 1
                    }
                },
        "pit": {
        "id": "0_uxAwILMTQxMV9ldmVudHMWTFhXQ3NrYWNSRDZMVlJzMlhPbjZVZwAWaEZZNUVOUF9SdTY5V0tMTzZyaEVtdwAAAAAAAA2Q6xZaeFkycDRKWVNxYXo0b252cXBLREtRCzE0MTFfZXZlbnRzFkxYV0Nza2FjUkQ2TFZSczJYT242VWcBFkMycTFXRmh2U3pDWXlPTXJtVlJUVWcAAAAAAAAs7BwWYmExNFdBNE9Sb1NNcklWNGgydURfUQEWTFhXQ3NrYWNSRDZMVlJzMlhPbjZVZwAA",
        "keep_alive": "1m"
            },
                "sort": [
                    {"ts": "asc"}
                ]
            }

I then invoke the query using :

result = elastic_connector.search(index="data_store", body=search_param, ignore=[400, 404])
print('result' , result)

The printed result is :

result {'error': {'root_cause': [{'type': 'action_request_validation_exception', 'reason': 'Validation Failed: 1: [indices] cannot be used with point in time;'}], 'type': 'action_request_validation_exception', 'reason': 'Validation Failed: 1: [indices] cannot be used with point in time;'}, 'status': 400}

I'm using elasticsearch 7.11 . There is a somewhat related issue here : https://github.com/elastic/elasticsearch/issues/69974 but I'm unsure if same issue applies here.

How should I construct the query to accept a PIT parameter ?

CodePudding user response:

From the docs:

If you provide a pit, you cannot specify a <target> in the request path. [1]

A search request with the pit parameter must not specify index, routing, and preference as these parameters are copied from the point in time. [2]

So create the PIT with index-information and use it without.

  • Related