[英]how to implement filters in elasticsearch using nest?
Assume I get some list of products after I search for the same, now I want to filter them based on say colour, size, etc. attributes. 假设我搜索了相同的产品后得到了一些产品列表,现在我想根据颜色,尺寸等属性对它们进行过滤。
How can I write nested queries? 如何编写嵌套查询?
Here's my search query: 这是我的搜索查询:
var result = client.Search<document>(s => s
.Analyzer("automplete").From(0).Size(20)
.Query(p => p
.MultiMatch(m => m
.OnFields(new[] { svalue })
.Query(value).Type(TextQueryType.PhrasePrefix)))
.Highlight(m => m.OnFields(n => n.OnField("some_field"))));
hope you are fine I think that you are traying to find in nested objets. 希望您一切都好,我认为您正在寻找嵌套的objets。 Elasticsearch have a speacil query for this needs is the NestedQuery Elasticsearch为此有一个特殊的查询是NestedQuery
` `
GET /my_index/blogpost/_search
{
"query": {
"bool": {
"must": [
{ "match": { "title": "eggs" }},
{
"nested": {
"path": "comments",
"query": {
"bool": {
"must": [
{ "match": { "comments.name": "john" }},
{ "match": { "comments.age": 28 }}
]
}}}}
]
}}}
` `
In you case, to access nested objet you should need add products.color for the criteria. 在这种情况下,要访问嵌套对象,您需要添加product.color作为标准。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.