2015-01-21 116 views
0
{ 
    "sort": [ 
    { 
     "is_active": "asc" 
    } 
    ], 
    "fields": [ 
    "is_job_seeking", "is_active" 
    ], 
    "query": { 
    "bool": { 
     "must": [ 
     { 
      "bool": { 
      "must": { 
       "term": { 
       "is_job_seeking": 1 
       } 
      } 
      } 
     } 
     ] 
    } 
    } 
} 

該查詢返回我擁有is_job_seeking=1,和is_active=0is_active=1所有文件和這很好,現在當我想提高成績。其中有is_active=1我有加boosting推進的查詢工作不正常

文件
{ 
    "sort": [ 
    { 
     "is_active": "asc" 
    } 
    ], 
    "fields": [ 
    "is_job_seeking", "is_active" 
    ], 
    "query": { 
    "bool": { 
     "must": [ 
     { 
      "bool": { 
      "must": { 
       "term": { 
       "is_job_seeking": 1 
       } 
      } 
      } 
     }, 
     { 
      "boosting": { 
      "positive": { 
       "term": { 
       "is_active": 1 
       } 
      }, 
      "negative": { 
       "term": { 
       "is_active": 0 
       } 
      }, 
      "negative_boost": 0.3 
      } 
     } 
     ] 
    } 
    } 
} 

但這給我只能用is_active=1

回答

0

結果試試這個:

{ 
    "sort": [ 
    { 
     "is_active": "asc" 
    } 
    ], 
    "fields": [ 
    "is_job_seeking", 
    "is_active" 
    ], 
    "query": { 
    "bool": { 
     "must": [ 
     { 
      "bool": { 
      "must": { 
       "term": { 
       "is_job_seeking": 1 
       } 
      } 
      } 
     } 
     ], 
     "should": [ 
     { 
      "boosting": { 
      "positive": { 
       "term": { 
       "is_active": 1 
       } 
      }, 
      "negative": { 
       "term": { 
       "is_active": 0 
       } 
      }, 
      "negative_boost": 0.3 
      } 
     } 
     ] 
    } 
    } 
}