If you can provide more information about your data or at least data fields in your elastic index community can help you more effectively. Since there is no more info available about your data/index I am assuming two fields in your index one is product_name which may contain product name with other details and another one is category which will of course contain from which category product belongs. For example -
{
"product_name" : "shoes - Midnight Blue"
"category" : ["Women's Shoes", "Women's Clothing"] ----> This document belongs to women's category.
}
Now as per my understanding you are looking to categories above product_name in respective category and want to provide some weight. So below query will fit for you. Please test against your index and suggest here.
GET ecommerce_data/_search
{
"query": {
"function_score": {
"query": {
"match": {
"product_name": "shoes"
}
},
"functions": [
{
"filter": {
"match":{
"category":"children's"
}
},
"weight": 3
},
{
"filter": { -----> Above document will match this filter
"match":{
"category":"women's"
}
},
"weight": 2
},
{
"filter": {
"match":{
"category":"men's"
}
},
"weight": 1
}
],
"score_mode": "max",
"boost_mode": "replace"
}
},
"_source": ["product_name","category"] -----> Verify with limited fields.
}