写一个查询来提高结果,如果它属于一个特定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" } } ] } } ] } }
}
- 如何在节点js中的ElasticSearch快照?
- ElasticSearch JS客户端search
- ElasticSearch – 聚合/分组:通过sorting和分页
- illegal_argument_exception请求包含无法识别的参数: – ElasticSearch索引创build
- 弹性search在启动时嗅探没有活的连接
- 如何阅读与node.js或JavaScript文件的行延迟,而不是在非阻塞行为?
- 弹性search创build基于时间的索引
- 如何确保在ElasticSearch盆景免费实例中使用Firebase FlashLight为每个对象build立索引
- Elasticsearch映射