Advertisement
frolkin28

es query

Jul 26th, 2022
1,002
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 7.33 KB | None | 0 0
  1. {
  2.     "query": {
  3.         "bool": {
  4.             "must": {
  5.                 "function_score": {
  6.                     "query": {
  7.                         "function_score": {
  8.                             "query": {
  9.                                 "bool": {
  10.                                     "should": [
  11.                                         {
  12.                                             "match_all": {}
  13.                                         },
  14.                                         {
  15.                                             "match": {
  16.                                                 "name": {
  17.                                                     "query": "Очищающее средство против морщин для сухой и жирной кожи, VENZEN Soft Cream Hydrating Nicotinamide Essence, 50",
  18.                                                     "boost": 5,
  19.                                                     "minimum_should_match": "60%"
  20.                                                 }
  21.                                             }
  22.                                         }
  23.                                     ]
  24.                                 }
  25.                             },
  26.                             "functions": [
  27.                                 {
  28.                                     "filter": {
  29.                                         "range": {
  30.                                             "price.local": {
  31.                                                 "gte": 92.0,
  32.                                                 "lte": 138.0
  33.                                             }
  34.                                         }
  35.                                     },
  36.                                     "weight": 1.4
  37.                                 }
  38.                             ]
  39.                         }
  40.                     },
  41.                     "functions": [
  42.                         {
  43.                             "filter": {
  44.                                 "bool": {
  45.                                     "must_not": {
  46.                                         "range": {
  47.                                             "adv_cpa_sort_price": {
  48.                                                 "gt": 0
  49.                                             }
  50.                                         }
  51.                                     },
  52.                                     "should": [
  53.                                         {
  54.                                             "range": {
  55.                                                 "adv_prices.others": {
  56.                                                     "gt": 0
  57.                                                 }
  58.                                             }
  59.                                         },
  60.                                         {
  61.                                             "range": {
  62.                                                 "adv_prices.catalog": {
  63.                                                     "gt": 0
  64.                                                 }
  65.                                             }
  66.                                         }
  67.                                     ]
  68.                                 }
  69.                             },
  70.                             "weight": 10,
  71.                             "script_score": {
  72.                                 "script": {
  73.                                     "lang": "painless",
  74.                                     "inline": "Math.log1p(doc[params.adv_field_others].value)",
  75.                                     "params": {
  76.                                         "adv_field_others": "adv_prices.others",
  77.                                         "adv_field_catalog": "adv_prices.catalog"
  78.                                     }
  79.                                 }
  80.                             }
  81.                         },
  82.                         {
  83.                             "filter": {
  84.                                 "range": {
  85.                                     "adv_cpa_sort_price": {
  86.                                         "gt": 0
  87.                                     }
  88.                                 }
  89.                             },
  90.                             "weight": 10,
  91.                             "script_score": {
  92.                                 "script": {
  93.                                     "lang": "painless",
  94.                                     "inline": "\n            Math.log1p(\n                doc[params.cpa_field].value >= params.min_price\n                ? doc[params.cpa_field].value\n                : params.min_price\n            )\n        ",
  95.                                     "params": {
  96.                                         "cpa_field": "adv_cpa_sort_price",
  97.                                         "min_price": 0.11
  98.                                     }
  99.                                 }
  100.                             }
  101.                         }
  102.                     ],
  103.                     "score_mode": "sum",
  104.                     "boost_mode": "sum"
  105.                 }
  106.             },
  107.             "filter": [
  108.                 {
  109.                     "bool": {
  110.                         "must_not": [
  111.                             {
  112.                                 "ids": {
  113.                                     "values": [
  114.                                         "product~1403193805"
  115.                                     ]
  116.                                 }
  117.                             }
  118.                         ]
  119.                     }
  120.                 },
  121.                 {
  122.                     "bool": {
  123.                         "must_not": [
  124.                             {
  125.                                 "term": {
  126.                                     "company.id": 2418473
  127.                                 }
  128.                             }
  129.                         ]
  130.                     }
  131.                 },
  132.                 {
  133.                     "term": {
  134.                         "category.id": 330606
  135.                     }
  136.                 },
  137.                 {
  138.                     "bool": {
  139.                         "must": [
  140.                             {
  141.                                 "term": {
  142.                                     "company.status": 0
  143.                                 }
  144.                             }
  145.                         ],
  146.                         "must_not": [
  147.                             {
  148.                                 "term": {
  149.                                     "company.holidays": datetime.date(2022,7,26)
  150.                                 }
  151.                             }
  152.                         ]
  153.                     }
  154.                 },
  155.                 {
  156.                     "terms": {
  157.                         "_doc_type_join": [
  158.                             "product"
  159.                         ]
  160.                     }
  161.                 }
  162.             ]
  163.         }
  164.     },
  165.     "_source": False,
  166.     "size": 10,
  167.     "from": 0,
  168.     "rescore": [
  169.         {
  170.             "grouping_mixup": {
  171.                 "group_field": "company.id",
  172.                 "decline_script": {
  173.                     "inline": "7.0 / (7.0 * params._pos + 10.0) + 0.3",
  174.                     "lang": "painless"
  175.                 }
  176.             },
  177.             "window_size": 1000
  178.         }
  179.     ],
  180.     "docvalue_fields": [
  181.         "_doc_type_join",
  182.         "_doc_type_join#*"
  183.     ]
  184. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement