Это синтаксис инициализатора объекта:
var boolQuery = new BoolQuery
{
Must = new QueryContainer[]
{
new MultiMatchQuery
{
Fields = Field<AdDocument>(p => p.Title, 1.5).And<AdDocument>(p => p.Description),
Query = "MyKeyword",
Fuzziness = Fuzziness.Auto
}
},
Filter = new QueryContainer[]
{
new TermQuery { Field = Field<AdDocument>(f => f.NoOfBedrooms), Value = 3 } &&
new TermQuery { Field = Field<AdDocument>(f => f.NoOfBathrooms), Value = 2 } &&
new NumericRangeQuery { Field = Field<AdDocument>(p => p.Price), GreaterThan = 2000 }
}
};
var searchResponse = _elasticClient.Search<AdDocument>(new SearchRequest<AdDocument>
{
Query = boolQuery
});
Это приведет к следующему DSL JSON:
{
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "MyKeyword",
"fuzziness": "AUTO",
"fields": [
"title^1.5",
"description"
]
}
}
],
"filter": [
{
"bool": {
"must": [
{
"term": {
"noOfBedrooms": {
"value": 3
}
}
},
{
"term": {
"noOfBathrooms": {
"value": 2
}
}
},
{
"range": {
"price": {
"gt": 2000.0
}
}
}
]
}
}
]
}
}
}