我正在尝试使用 flex 5.5建立强制的搜索(使用 flex 2。*我找到了有关如何执行此操作的信息,但是在5.5中我无法找到)
如果用户将选择使用某些属性进行筛选,那么我想显示金额提示的东西并不稀奇,类似于商店。 Image for visualisation
数据集示例:
[
{
"id" : "978-0641723445",
"cat" : ["book","hardcover"],
"name" : "The Lightning Thief",
"author" : "Rick Riordan",
"series_t" : "Percy Jackson and the Olympians",
"sequence_i" : 1,
"genre_s" : "fantasy",
"inStock" : true,
"price" : 12.50,
"pages_i" : 384
}
,
{
"id" : "978-1423103349",
"cat" : ["book","paperback"],
"name" : "The Sea of Monsters",
"author" : "Rick Riordan",
"series_t" : "Percy Jackson and the Olympians",
"sequence_i" : 2,
"genre_s" : "fantasy",
"inStock" : true,
"price" : 6.49,
"pages_i" : 304
}
,
{
"id" : "978-1857995879",
"cat" : ["book","paperback"],
"name" : "Sophie's World : The Greek Philosophers",
"author" : "Jostein Gaarder",
"sequence_i" : 1,
"genre_s" : "fantasy",
"inStock" : true,
"price" : 3.07,
"pages_i" : 64
}
,
{
"id" : "978-1933988177",
"cat" : ["book","paperback"],
"name" : "Lucene in Action, Second Edition",
"author" : "Michael McCandless",
"sequence_i" : 1,
"genre_s" : "IT",
"inStock" : true,
"price" : 30.50,
"pages_i" : 475
}
]
谢谢!
最佳答案
您只需要使用aggs即可代替多方面的功能。聚合比方面要强大得多。
例如:
GET index/_search
{
"aggs" : {
"countries" : {
"terms" : { "field" : "country" }
},
"types" : {
"terms" : { "field" : "type" }
}
}
}
然后,如果用户单击“构面”,则只需在bool查询中添加filter子句(这将更新所有构面计数),或者添加post_filter仅筛选结果(不影响聚合)。
关于database - 弹性5.5,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44997408/