Hi I want to group elastic search query result bases on a specific field. I have gone through collapse and aggregation doc but cant find how to achieve this. Here is an example Lets say I have three documents:-
{
"id":"1"
"sub":"1_1a"
"name" : "TV",
"make" : "samsung",
"model":"plasma"}
{
"id":"2"
"subid":"1_2a"
"name" : "TV",
"make" : "samsung",
"model":"plasma_different_model"}
{
"id":"3"
"subid":"1_3a"
"name" : "TV",
"make" : "samsung",
"model":"plasma_another_different_model"}
I want to group my query result by subid with only 1st part of sub-id="1" splitting it from the underscore.
So my aim is to get only one doc as search result with "sub-id"="1" according to relevance. How can i achieve this?
You can do it by a runtime field in such query
Response