Guest User

Untitled

a guest
Jun 26th, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 5.19 KB | None | 0 0
  1. // Non boosted
  2. {
  3.   "query": {
  4.     "constant_score": {
  5.       "filter": {
  6.         "bool": {
  7.           "must": [
  8.             {
  9.               "term": {
  10.                 "state": 1
  11.               }
  12.             },
  13.             {
  14.               "term": {
  15.                 "cat_state": 1
  16.               }
  17.             },
  18.             {
  19.               "bool": {
  20.                 "should": [
  21.                   {
  22.                     "range": {
  23.                       "end_date": {
  24.                         "gte": "2019-06-26 17:38:59"
  25.                       }
  26.                     }
  27.                   },
  28.                   {
  29.                     "term": {
  30.                       "end_date": "0"
  31.                     }
  32.                   },
  33.                   {
  34.                     "bool": {
  35.                       "must_not": [
  36.                         {
  37.                           "exists": {
  38.                             "field": "end_date"
  39.                           }
  40.                         }
  41.                       ]
  42.                     }
  43.                   }
  44.                 ]
  45.               }
  46.             },
  47.             {
  48.               "bool": {
  49.                 "should": [
  50.                   {
  51.                     "range": {
  52.                       "publish_end_date": {
  53.                         "gte": "2019-06-26 17:38:59"
  54.                       }
  55.                     }
  56.                   },
  57.                   {
  58.                     "term": {
  59.                       "publish_end_date": "0"
  60.                     }
  61.                   },
  62.                   {
  63.                     "bool": {
  64.                       "must_not": [
  65.                         {
  66.                           "exists": {
  67.                             "field": "publish_end_date"
  68.                           }
  69.                         }
  70.                       ]
  71.                     }
  72.                   }
  73.                 ]
  74.               }
  75.             }
  76.           ],
  77.           "should": [
  78.             {
  79.               "match": {
  80.                 "title": {
  81.                   "query": "dna",
  82.                   "operator": "and",
  83.                   "boost": 1.7
  84.                 }
  85.               }
  86.             },
  87.             {
  88.               "match": {
  89.                 "description": {
  90.                   "query": "dna",
  91.                   "operator": "and",
  92.                   "boost": 0.7
  93.                 }
  94.               }
  95.             }
  96.           ],
  97.           "must_not": [],
  98.           "filter": []
  99.         }
  100.       }
  101.     }
  102.   }
  103. }
  104.  
  105. //Boosted
  106. {
  107.   "query": {
  108.     "boosting": {
  109.       "positive": {
  110.         "bool": {
  111.           "must": [
  112.             {
  113.               "term": {
  114.                 "state": 1
  115.               }
  116.             },
  117.             {
  118.               "term": {
  119.                 "cat_state": 1
  120.               }
  121.             },
  122.             {
  123.               "bool": {
  124.                 "should": [
  125.                   {
  126.                     "range": {
  127.                       "end_date": {
  128.                         "gte": "2019-06-26+17:42:52"
  129.                       }
  130.                     }
  131.                   },
  132.                   {
  133.                     "term": {
  134.                       "end_date": "0"
  135.                     }
  136.                   },
  137.                   {
  138.                     "bool": {
  139.                       "must_not": [
  140.                         {
  141.                           "exists": {
  142.                             "field": "end_date"
  143.                           }
  144.                         }
  145.                       ]
  146.                     }
  147.                   }
  148.                 ]
  149.               }
  150.             },
  151.             {
  152.               "bool": {
  153.                 "should": [
  154.                   {
  155.                     "range": {
  156.                       "publish_end_date": {
  157.                         "gte": "2019-06-26+17:42:52"
  158.                       }
  159.                     }
  160.                   },
  161.                   {
  162.                     "term": {
  163.                       "publish_end_date": "0"
  164.                     }
  165.                   },
  166.                   {
  167.                     "bool": {
  168.                       "must_not": [
  169.                         {
  170.                           "exists": {
  171.                             "field": "publish_end_date"
  172.                           }
  173.                         }
  174.                       ]
  175.                     }
  176.                   }
  177.                 ]
  178.               }
  179.             }
  180.           ],
  181.           "should": [
  182.             {
  183.               "match": {
  184.                 "title": {
  185.                   "query": "dna",
  186.                   "operator": "and",
  187.                   "boost": 1.7
  188.                 }
  189.               }
  190.             },
  191.             {
  192.               "match": {
  193.                 "description": {
  194.                   "query": "dna",
  195.                   "operator": "and",
  196.                   "boost": 0.7
  197.                 }
  198.               }
  199.             }
  200.           ],
  201.           "must_not": [],
  202.           "filter": []
  203.         }
  204.       },
  205.       "negative": {
  206.         "terms": {
  207.           "_index": [
  208.             "index_a",
  209.             "index_c",
  210.             "index_d",
  211.             "index_e",
  212.             "index_f"
  213.           ]
  214.         }
  215.       },
  216.       "negative_boost": 0.5
  217.     }
  218.   }
  219. }
Advertisement
Add Comment
Please, Sign In to add comment