elasticsearch:根据参数获取自定义结果

时间:2017-10-16 06:40:40

标签: elasticsearch

我正在探索elasticsearch。我有一些像这样的索引文件

[
    {"assetName" :"book1","source":"Shelf1"},
    {"assetName" :"book2","source":"Shelf1"},
    {"assetName" :"book3","source":"Shelf1"},
    {"assetName" :"book11","source":"Shelf2"},
    {"assetName" :"book12","source":"Shelf2"},
    {"assetName" :"book13","source":"Shelf2"},
    {"assetName" :"book21","source":"Shelf3"},
    {"assetName" :"book22","source":"Shelf3"}
]

现在,如果我将 book 作为搜索参数传递,那么它应该首先根据来自每个(Shelf1,shelf2,shelf3)的源返回文档,然后再返回其他文档结果。所以结果json将是

[
    {"assetName" :"book1","source":"Shelf1"},
    {"assetName" :"book11","source":"Shelf2"},
    {"assetName" :"book21","source":"Shelf3"},
    {"assetName" :"book2","source":"Shelf1"},
    {"assetName" :"book3","source":"Shelf1"},
    {"assetName" :"book12","source":"Shelf2"},
    {"assetName" :"book13","source":"Shelf2"},
    {"assetName" :"book22","source":"Shelf3"}
]

是否可以在elasticsearch

0 个答案:

没有答案