Hi,
I am trying to do a sequence searching in elastic search using nested fields.
I have two fields:
- Event Id:
- Events - which is a nested field. This nested field has two fields:
a) Id: Any number associated with the event
b) Event Name: Name of the event happened
I am trying to see sequences in Event Names and want to return the Id of the first sequence match.
Pasting my index mappings and the sorting that I have done till now.
Can somebody please suggest, how I can go about with the sequence search. Thanks in advance.
PUT nested_events
{
"mappings": {
"log": {
"properties": {
"Events": {
"type": "nested"
},
"EventID":
{
"type" : "integer"
}
}
}
}
}
PUT /nested_events/log/1
{
"EventID": 3,
"Events": [
{
"Id": 10,
"Event Name": "A"
},
{
"Id": 11,
"Event Name": "B"
},
{
"Id": 12,
"Event Name": "C"
},
{
"Id": 13,
"Event Name": "B"
},{
"Id": 14,
"Event Name": "A"
},
{
"Id": 15,
"Event Name": "B"
},
{
"Id": 16,
"Event Name": "A"
},
{
"Id": 17,
"Event Name": "A"
},
{
"Id": 18,
"Event Name": "C"
}
]
}
And this is my sort query on the nested fields:
GET /nested_events/_search
{
"sort": {
"Events.ID": {
"order": "asc",
"mode": "min"
}
}
Input: AB
Expected Output:
Id: 10
Id: 14