Hi Everyone,
Basically my requirement is little complex so I have to give example to explain better. Below is my indexed document (sort of, not completely)
"productid": 181750,
"productname": "Synthetic Promotional Tennis Ball",
"productname_suggest": "Synthetic Promotional Tennis Ball",
"saleprice": 1.15,
"filename": "Promotional-Synthetic-Promotional-Tennis-Ball-181750_red.jpg",
"minquantity": 150,
"imprinttype": "Silk Screen",
"imprinttypeids": "16",
"madeinUSA": false,
"themetype": "Tennis",
"themetype_id": "404",
"colorArray": [
"Blue",
"Green",
"Orange",
"Pink",
"Purple",
"Red",
"White",
"Yellow"
],
"topsellersOrders": 1,
"topsellersQuantity": 300,
"region": "SE",
"regionnmlong": "Southeast",
"createDate": "2017-04-27T12:58:42.387",
"freeShipping": false,
"issale": true,
"tN_Width": 160,
"tN_Height": 160,
"subcategory_id_list": "161",
"subcategory_nm_list": "Toys",
"subcategory_id_main": 161,
"subcategory_nm_main": "Toys",
"subcategory_nm_main_suggest": "Toys",
"category_id_list": "36",
"category_nm_list": "Games & Toys",
"category_id_main": 36,
"category_nm_main": "Games & Toys",
"category_nm_main_suggest": "Games & Toys",
"subcategoryURL": "/Promotional-Toys-Custom-36-161.html",
"categoryURL": "/Promotional-GamesandToys-Custom-36.html",
"themetype_url": "/Promotional-Tennis-Products-404.html",
"productFeaturedOrder": 102
and the search query I use is as below:
GET /allproducts_beta/product/_search
{
"from": 0,
"size": 10000,
"query": {
"multi_match" : {
"query": "pink color frisbee",
"type": "cross_fields",
"fields": [ "productname", "brandname", "imprinttype", "themetype", "offerthemetype", "industrythemetype", "schoolthemetype", "eventthemetype", "awarenessthemetype", "tradeshowthemetype", "colorArray", "materialArray", "subcategory_nm_list", "subcategory_nm_main", "category_nm_list", "category_nm_main", "ProductFeaturedOrder", "smartTags"],
"operator": "or",
"minimum_should_match": "70%"
}
}
}
Basically this query returns document hits (and please correct me if my understanding of this queries working is wrong) in order as below:
STEP 1: On top are document hits that contain all 3 search words "pink" , "color" and "frisbee" from the search phrase individually in any of the fields.
STEP 2: Next are the document hits that contain any 2 word from the search phrase "pink color frisbee" and these would be appended to result as well by ElasticSearch.
STEP 3: Lastly come document hits that may contain ANY one of the word from the search phrase "pink color frisbee" and these documents would also be appended.
STEP 4: Obviously these would be by DEFAULT sorted based on "_score" and returned by ElasticSearch API.
Looking at these results, we understand that the final results sent by ElasticSearch is actually created of 3 parts. The part on top is containing all 3 search words followed by part that contains 2 search words and finally only 1 search word which is at bottom of results since their _score is least. Now my requirement here is, very specific, I want that at each STEP 1, 2 & 3 I want that my records should be "sort" 'ed based another column "productFeaturedOrder" inside each part while keeping the order of part 1, 2 and 3 intact before result is sent back.