现在有一个像 github 搜索的场景,
指定一个 SearchKeyword
需要去分别搜索" github "索引( Index )下的
" repositories , users , issues , code "四个类型( Type )并得到结果
最简单的方法自然是指定不同的类型( type )和搜索条件进行四次搜索
那么有没有办法在一次搜索中完成搜索,对不同的索引指定不同的条件
现在有一个像 github 搜索的场景,
指定一个 SearchKeyword
需要去分别搜索" github "索引( Index )下的
" repositories , users , issues , code "四个类型( Type )并得到结果
最简单的方法自然是指定不同的类型( type )和搜索条件进行四次搜索
那么有没有办法在一次搜索中完成搜索,对不同的索引指定不同的条件
可以采用以下写法
语法:
GET /index1,index2/type1/type2/_search
{
......
}
例子
GET /index/repositories,users,issues,code/_search
{
"query":{
"match":{
"_all":"SearchKeyword"
}
}
}
1 回答2.7k 阅读
1 回答1.2k 阅读
1 回答794 阅读
这里最后还是选择了搜索四次