Elastic query

Hello,

Il would like to make a query that is use to analyze the data to identify, for each distinct value of the field « Field_a », if the values of the field_b change from « value_b_1 » to « value_b_2 » over a given period (e.g., 30 days).

Example :

Log_1 :

Field_a : value_a_1
Field_b :value_b_1

Log_2

Field_a : value_a_1
Field_b : value_b_2

Log_3

Field_a : value_a_2
Field_b : value_b_1

Log_4

Field_a : value_a_2
Field_b : value_b_1

In this example, the query retrun log_ 3.

Someone can help-me?

Thanks