写一个查询来提高结果,如果它属于一个特定types的字段

我正在使用Elasticsearch与Node.js现在我遇到的问题是,我想编写一个查询,如果我想提高我的结果,如果它属于特定types的字段,例如,如果我有索引:商人types:餐厅,时尚两种types都有一个字段shop_name ,现在我想我的search结果得到提升到2倍,如果shop_name是餐厅types而不是时尚。

我已经写了我的查询如下

index: 'merchants', type: ['fashion', 'restaurant'], body: { "query":{ bool: { "disable_coord": true, should: [ { "constant_score": { boost: 1.00, // HERE BOOST IS 1 as field is in type FASHION "query": { "wildcard" : { "fashion.shop_name" : last_wildcard_string } } } }, { "constant_score": { boost: 2.00, // HERE BOOST IS 2 as field is in type RESTAURANT "query": { "wildcard" : { "restaurant.shop_name" : last_wildcard_string } } } } ], "minimum_should_match": 1 } } } 

现在我不知道为什么,但以上代码工作罚款2-3个月之前,我猜,但现在我不知道为什么上面的代码不返回任何东西。

有人可以告诉我,我做错了,因为它之前工作正常。 否则只是告诉我, 这是不是一个正确的方式来写fashion.shop_name来定义typesfashion的shop_name

不pipe怎么说,多谢拉。

尝试这个

 { "query" : { "bool" : { "should" : [{ "bool" : { "must" : [{ "wildcard" : { "shop_name" : { "value" : "last_wildcard_string", "boost" : 2.0 } } }, { "term" : { "_type" : "restaurant" } } ] } }, { "bool" : { "must" : [{ "wildcard" : { "shop_name" : { "value" : "last_wildcard_string", "boost" : 1.0 } } }, { "term" : { "_type" : "fashion" } } ] } } ] } } 

}