Amazon web services ElasticSearch嵌套QueryParsingException布尔查询不支持筛选器
我正在使用NEST 2.3.2查询ElasticSearch,需要基于可选布尔值为FollowUpDateTime字段创建一个条件过滤器。如果这个布尔值Amazon web services ElasticSearch嵌套QueryParsingException布尔查询不支持筛选器,amazon-web-services,elasticsearch,nest,Amazon Web Services,elasticsearch,Nest,我正在使用NEST 2.3.2查询ElasticSearch,需要基于可选布尔值为FollowUpDateTime字段创建一个条件过滤器。如果这个布尔值 var containers = new QueryContainer[7]; //Size is based on hte number of search parameters.. var descriptor = ne
var containers = new QueryContainer[7];
//Size is based on hte number of search parameters..
var descriptor = new QueryContainerDescriptor<EsNoteModel>();
var filters = new QueryContainer[1];
var filterdescriptor = new QueryContainerDescriptor<EsNoteModel>();
/*...... some code for other parameters here .....*/
if (hasFollowUpDate.HasValue)
{
if ((bool) hasFollowUpDate)
{
//If true shows only with a non-blank follow-up date
filters[0] = filterdescriptor.Exists(ff => ff.Field("FollowUpDateTime"));
}
else
{
//If false shows only notes with a blank follow-up date
filters[0] = filterdescriptor.Missing(ff => ff.Field("FollowUpDateTime"));
}
}
/*...... CALL to ES below .....*/
var result = ElasticSearchClient.Search<EsNoteModel>(body => body
.From(offset - 1)
.Size(rows)
.Query(q => q
.Bool(b => b
.Must(containers)
.Filter(f => f.Bool(t => t.Must(filters)))
)
)
.Sort(s => s
.Field(f => f
.Field(p => p.NoteDate)
.Order(SortOrder.Descending)))
);
- 为true-希望查看日期非空的所有记录
- 是假的-没有日期的记录
- 为空-显示所有记录
var containers = new QueryContainer[7];
//Size is based on hte number of search parameters..
var descriptor = new QueryContainerDescriptor<EsNoteModel>();
var filters = new QueryContainer[1];
var filterdescriptor = new QueryContainerDescriptor<EsNoteModel>();
/*...... some code for other parameters here .....*/
if (hasFollowUpDate.HasValue)
{
if ((bool) hasFollowUpDate)
{
//If true shows only with a non-blank follow-up date
filters[0] = filterdescriptor.Exists(ff => ff.Field("FollowUpDateTime"));
}
else
{
//If false shows only notes with a blank follow-up date
filters[0] = filterdescriptor.Missing(ff => ff.Field("FollowUpDateTime"));
}
}
/*...... CALL to ES below .....*/
var result = ElasticSearchClient.Search<EsNoteModel>(body => body
.From(offset - 1)
.Size(rows)
.Query(q => q
.Bool(b => b
.Must(containers)
.Filter(f => f.Bool(t => t.Must(filters)))
)
)
.Sort(s => s
.Field(f => f
.Field(p => p.NoteDate)
.Order(SortOrder.Descending)))
);
答复如下:
var containers = new QueryContainer[7];
//Size is based on hte number of search parameters..
var descriptor = new QueryContainerDescriptor<EsNoteModel>();
var filters = new QueryContainer[1];
var filterdescriptor = new QueryContainerDescriptor<EsNoteModel>();
/*...... some code for other parameters here .....*/
if (hasFollowUpDate.HasValue)
{
if ((bool) hasFollowUpDate)
{
//If true shows only with a non-blank follow-up date
filters[0] = filterdescriptor.Exists(ff => ff.Field("FollowUpDateTime"));
}
else
{
//If false shows only notes with a blank follow-up date
filters[0] = filterdescriptor.Missing(ff => ff.Field("FollowUpDateTime"));
}
}
/*...... CALL to ES below .....*/
var result = ElasticSearchClient.Search<EsNoteModel>(body => body
.From(offset - 1)
.Size(rows)
.Query(q => q
.Bool(b => b
.Must(containers)
.Filter(f => f.Bool(t => t.Must(filters)))
)
)
.Sort(s => s
.Field(f => f
.Field(p => p.NoteDate)
.Order(SortOrder.Descending)))
);
# Response:
{
"error" : "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[-t7SwBo_TjeH_98h_56ANw][customernote][0]: RemoteTransportException[[Neophyte][inet[/x.x.x.x:y]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[customernote][0]: from[0],size[25],sort[<custom:\"NoteDate\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@2d55231>!]: Parse Failure [Failed to parse source [{\r\n \"from\": 0,\r\n \"size\": 25,\r\n \"sort\": [\r\n {\r\n \"NoteDate\": {\r\n \"order\": \"desc\"\r\n }\r\n }\r\n ],\r\n \"query\": {\r\n \"bool\": {\r\n \"must\": [\r\n {\r\n \"match\": {\r\n \"CustomerId\": {\r\n \"query\": \"28_10855\"\r\n }\r\n }\r\n }\r\n ],\r\n \"filter\": [\r\n {\r\n \"bool\": {\r\n \"must\": [\r\n {\r\n \"exists\": {\r\n \"field\": \"FollowUpDateTime\"\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n}]]]; nested: QueryParsingException[[customernote] bool query does not support [filter]]; }{[TOOugCq3ROqF9CGnHIay2g][customernote][1]: SearchParseException[[customernote][1]: from[0],size[25],sort[<custom:\"NoteDate\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@562f97b5>!]: Parse Failure [Failed to parse source [{\r\n \"from\": 0,\r\n \"size\": 25,\r\n \"sort\": [\r\n {\r\n \"NoteDate\": {\r\n \"order\": \"desc\"\r\n }\r\n }\r\n ],\r\n \"query\": {\r\n \"bool\": {\r\n \"must\": [\r\n {\r\n \"match\": {\r\n \"CustomerId\": {\r\n \"query\": \"28_10855\"\r\n }\r\n }\r\n }\r\n ],\r\n \"filter\": [\r\n {\r\n \"bool\": {\r\n \"must\": [\r\n {\r\n \"exists\": {\r\n \"field\": \"FollowUpDateTime\"\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n}]]]; nested: QueryParsingException[[customernote] bool query does not support [filter]]; }{[TOOugCq3ROqF9CGnHIay2g][customernote][2]: SearchParseException[[customernote][2]: from[0],size[25],sort[<custom:\"NoteDate\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@394cf46e>!]: Parse Failure [Failed to parse source [{\r\n \"from\": 0,\r\n \"size\": 25,\r\n \"sort\": [\r\n {\r\n \"NoteDate\": {\r\n \"order\": \"desc\"\r\n }\r\n }\r\n ],\r\n \"query\": {\r\n \"bool\": {\r\n \"must\": [\r\n {\r\n \"match\": {\r\n \"CustomerId\": {\r\n \"query\": \"28_10855\"\r\n }\r\n }\r\n }\r\n ],\r\n \"filter\": [\r\n {\r\n \"bool\": {\r\n \"must\": [\r\n {\r\n \"exists\": {\r\n \"field\": \"FollowUpDateTime\"\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n}]]]; nested: QueryParsingException[[customernote] bool query does not support [filter]]; }{[-t7SwBo_TjeH_98h_56ANw][customernote][3]: RemoteTransportException[[Neophyte][inet[/x.x.x.x:y]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[customernote][3]: from[0],size[25],sort[<custom:\"NoteDate\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@46d07ba8>!]: Parse Failure [Failed to parse source [{\r\n \"from\": 0,\r\n \"size\": 25,\r\n \"sort\": [\r\n {\r\n \"NoteDate\": {\r\n \"order\": \"desc\"\r\n }\r\n }\r\n ],\r\n \"query\": {\r\n \"bool\": {\r\n \"must\": [\r\n {\r\n \"match\": {\r\n \"CustomerId\": {\r\n \"query\": \"28_10855\"\r\n }\r\n }\r\n }\r\n ],\r\n \"filter\": [\r\n {\r\n \"bool\": {\r\n \"must\": [\r\n {\r\n \"exists\": {\r\n \"field\": \"FollowUpDateTime\"\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n}]]]; nested: QueryParsingException[[customernote] bool query does not support [filter]]; }{[TOOugCq3ROqF9CGnHIay2g][customernote][4]: SearchParseException[[customernote][4]: from[0],size[25],sort[<custom:\"NoteDate\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@74fb3710>!]: Parse Failure [Failed to parse source [{\r\n \"from\": 0,\r\n \"size\": 25,\r\n \"sort\": [\r\n {\r\n \"NoteDate\": {\r\n \"order\": \"desc\"\r\n }\r\n }\r\n ],\r\n \"query\": {\r\n \"bool\": {\r\n \"must\": [\r\n {\r\n \"match\": {\r\n \"CustomerId\": {\r\n \"query\": \"28_10855\"\r\n }\r\n }\r\n }\r\n ],\r\n \"filter\": [\r\n {\r\n \"bool\": {\r\n \"must\": [\r\n {\r\n \"exists\": {\r\n \"field\": \"FollowUpDateTime\"\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n}]]]; nested: QueryParsingException[[customernote] bool query does not support [filter]]; }]",
"status" : 400
}
获取响应错误:
var containers = new QueryContainer[7];
//Size is based on hte number of search parameters..
var descriptor = new QueryContainerDescriptor<EsNoteModel>();
var filters = new QueryContainer[1];
var filterdescriptor = new QueryContainerDescriptor<EsNoteModel>();
/*...... some code for other parameters here .....*/
if (hasFollowUpDate.HasValue)
{
if ((bool) hasFollowUpDate)
{
//If true shows only with a non-blank follow-up date
filters[0] = filterdescriptor.Exists(ff => ff.Field("FollowUpDateTime"));
}
else
{
//If false shows only notes with a blank follow-up date
filters[0] = filterdescriptor.Missing(ff => ff.Field("FollowUpDateTime"));
}
}
/*...... CALL to ES below .....*/
var result = ElasticSearchClient.Search<EsNoteModel>(body => body
.From(offset - 1)
.Size(rows)
.Query(q => q
.Bool(b => b
.Must(containers)
.Filter(f => f.Bool(t => t.Must(filters)))
)
)
.Sort(s => s
.Field(f => f
.Field(p => p.NoteDate)
.Order(SortOrder.Descending)))
);
# Response:
{
"error" : "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[TOOugCq3ROqF9CGnHIay2g][customernote][0]: SearchParseException[[customernote][0]: from[0],size[25],sort[<custom:\"NoteDate\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@4839a60c>!]: Parse Failure [Failed to parse source [{\r\n \"from\": 0,\r\n \"size\": 25,\r\n \"sort\": [\r\n {\r\n \"NoteDate\": {\r\n \"order\": \"desc\"\r\n }\r\n }\r\n ],\r\n \"query\": {\r\n \"bool\": {\r\n \"must\": [\r\n {\r\n \"match\": {\r\n \"CustomerId\": {\r\n \"query\": \"2810855\"\r\n }\r\n }\r\n }\r\n ],\r\n \"filter\": [\r\n {\r\n \"exists\": {\r\n \"field\": \"FollowUpDateTime\"\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n}]]]; nested: QueryParsingException[[customernote] bool query does not support [filter]]; }{[-t7SwBo_TjeH_98h_56ANw][customernote][1]: RemoteTransportException[[Neophyte][inet[/x.x.x.x:y]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[customernote][1]: from[0],size[25],sort[<custom:\"NoteDate\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@21d845ae>!]: Parse Failure [Failed to parse source [{\r\n \"from\": 0,\r\n \"size\": 25,\r\n \"sort\": [\r\n {\r\n \"NoteDate\": {\r\n \"order\": \"desc\"\r\n }\r\n }\r\n ],\r\n \"query\": {\r\n \"bool\": {\r\n \"must\": [\r\n {\r\n \"match\": {\r\n \"CustomerId\": {\r\n \"query\": \"2810855\"\r\n }\r\n }\r\n }\r\n ],\r\n \"filter\": [\r\n {\r\n \"exists\": {\r\n \"field\": \"FollowUpDateTime\"\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n}]]]; nested: QueryParsingException[[customernote] bool query does not support [filter]]; }{[-t7SwBo_TjeH_98h_56ANw][customernote][2]: RemoteTransportException[[Neophyte][inet[/x.x.x.x:y]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[customernote][2]: from[0],size[25],sort[<custom:\"NoteDate\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@6124d214>!]: Parse Failure [Failed to parse source [{\r\n \"from\": 0,\r\n \"size\": 25,\r\n \"sort\": [\r\n {\r\n \"NoteDate\": {\r\n \"order\": \"desc\"\r\n }\r\n }\r\n ],\r\n \"query\": {\r\n \"bool\": {\r\n \"must\": [\r\n {\r\n \"match\": {\r\n \"CustomerId\": {\r\n \"query\": \"2810855\"\r\n }\r\n }\r\n }\r\n ],\r\n \"filter\": [\r\n {\r\n \"exists\": {\r\n \"field\": \"FollowUpDateTime\"\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n}]]]; nested: QueryParsingException[[customernote] bool query does not support [filter]]; }{[TOOugCq3ROqF9CGnHIay2g][customernote][3]: SearchParseException[[customernote][3]: from[0],size[25],sort[<custom:\"NoteDate\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@f884425>!]: Parse Failure [Failed to parse source [{\r\n \"from\": 0,\r\n \"size\": 25,\r\n \"sort\": [\r\n {\r\n \"NoteDate\": {\r\n \"order\": \"desc\"\r\n }\r\n }\r\n ],\r\n \"query\": {\r\n \"bool\": {\r\n \"must\": [\r\n {\r\n \"match\": {\r\n \"CustomerId\": {\r\n \"query\": \"2810855\"\r\n }\r\n }\r\n }\r\n ],\r\n \"filter\": [\r\n {\r\n \"exists\": {\r\n \"field\": \"FollowUpDateTime\"\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n}]]]; nested: QueryParsingException[[customernote] bool query does not support [filter]]; }{[-t7SwBo_TjeH_98h_56ANw][customernote][4]: RemoteTransportException[[Neophyte][inet[/x.x.x.x:y]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[customernote][4]: from[0],size[25],sort[<custom:\"NoteDate\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@77228f64>!]: Parse Failure [Failed to parse source [{\r\n \"from\": 0,\r\n \"size\": 25,\r\n \"sort\": [\r\n {\r\n \"NoteDate\": {\r\n \"order\": \"desc\"\r\n }\r\n }\r\n ],\r\n \"query\": {\r\n \"bool\": {\r\n \"must\": [\r\n {\r\n \"match\": {\r\n \"CustomerId\": {\r\n \"query\": \"2810855\"\r\n }\r\n }\r\n }\r\n ],\r\n \"filter\": [\r\n {\r\n \"exists\": {\r\n \"field\": \"FollowUpDateTime\"\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n}]]]; nested: QueryParsingException[[customernote] bool query does not support [filter]]; }]",
"status" : 400
}
#响应:
{
“错误”:“SearchPhaseExecutionException[未能执行阶段[query],所有碎片均失败;碎片失败{[TOOugCq3ROqF9CGnHIay2g][customernote][0]:SearchParseException[[customernote][0]:from[0],size[25],sort[!]:解析失败[未能解析源[{\r\n\“from\”:0\r\n\“size\”:25\r\n\“sort\:[\r\n\”:{\r\n\'order\':\'desc\'\r\n}\r\n}\r\n],\r\n\'query\':{\r\n\'bool\':{\r\n\'must\':[\r\n{\r\n\'match\':{\r\n\'CustomerId\':{\r\n\'query\':\'2810855\'\r\n}\r\n}\r\n}\r\n\'{\r\n\“field\”:\“FollowUpDateTime\”\r\n}\r\n]\r\n}\r\n}]];嵌套的:QueryParsingException[[customernote]bool查询不支持[filter]];}{[-t7SwBo U Tjeh98h\u 56ANw][customernote 1]:RemoteTransportException[[Neophyte][inet][x.x.x.x:y]][索引:数据/读取/搜索[阶段/查询]];嵌套:SearchParseException[[customernote][1]:from[0],size[25],sort[!]:解析失败[未能解析源[{\r\n\”from\”:0\r\n\“size\”:25\r\n\“sort\”:[\r\n{\r\n\“NoteDate\”:{\r\n\“order\”:“desc匹配\“:{\r\n \“CustomerId\”:{\r\n \“query\”:\“2810855\”\r\n}\r\n}\r\n}\r\n],\r\n \“filter\”:[\r\n{\r\n \“exists\”:{\r\n \“field\”:“FollowUpDateTime\”\r\n}\r\n}\r\n}\r\n}\r\n}\r\n]];嵌套异常:QueryParsing[[customernote]bool查询不支持[filter]];{[-t7SwBo_TjeH_98h_56ANw][customernote][2]:RemoteTransportException[[Neophyte][inet[[x.x.x.x:y]][Indexes:data/read/search[phase/query]];嵌套:SearchParseException[[customernote][2]:from[0],size[25],sort[!]:解析失败[解析源[{\r\n\“from\”:0\r\n\”大小\“:25、\r\n\“sort\”:[\r\n{\r\n\“NoteDate\”:{\r\n\“order\”:“desc\”\r\n}\r\n}\r\n],\r\n\“query\”:{\r\n\“bool\”:{\r\n\“must\”:[\r\n{\r\n\“match\”:{\r\n\“CustomerId\”:{\r\n\“query 2810855\”:{\r\n\r\r\n}],\r\n“filter\”:[\r\n{\r\n\“exists\”:{\r\n“field\”:“FollowUpDateTime\”\r\n}\r\n]\r\n}\r\n}\r\n}]];嵌套:QueryParsingException[[customernote]布尔查询不支持[filter];}{[Tooug3RoQF9CgnChiay2G][customernote 3]:SearchParsexException[[customernote 3]:from[0]、大小[25]、排序[!]:解析失败[未能解析源[{\r\n\“from\”:0、\r\n\“size\”:25、\r\n\“sort\”:[\r\n{\r\n\“NoteDate\”:{\r\n\“order\”:\“desc\”\r\n:\r\n}\r\n],\r\n\“query\”:{\r\n\“bool\”:{\r\n\“必须”:{\r\n\“匹配”:{\r\n\r\r\n{\r\n\'query\':\'2810855\'\r\n}\r\n}\r\n}\r\n],\r\n\'filter\':[\r\n{\r\n\'exists\':{\r\n\'field\':\'FollowUpDateTime\'\r\n}\r\n]\r\n}\r\n}\r\n}\r\n}]];嵌套的:QueryParsingException[[customernote bool查询不支持[filter]];{[-t7SwBo_TjeH_98h_56ANw][customernote][4]:RemoteTransportException[[Neophyte][inet][x.x.x.x:y]][index:data/read/search[phase/query]];nested:SearchParseException[[customernote][4]:from[0],size[25],sort[!]:解析失败[未能解析源[\r\n\'from\:0],\r\n\'size\'size\\\:25]:[\r\n\\'s\\\\\日期\':{\r\n\'order\':\'desc\'\r\n}\r\n}\r\n],\r\n\'query\':{\r\n\'bool\':{\r\n\'must\':[\r\n{\r\n\'match\':{\r\n\'CustomerId\':{\r\n\'query 2810855\'\r\n}\r\n}\r\n}\r\n\':{\r\n\“field\”:\“FollowUpDateTime\”\r\n}\r\n]\r\n}\r\n}\r\n}]];嵌套:QueryParsingException[[customernote]布尔查询不支持[filter]];}],
“地位”:400
}
基本相同的错误
var containers = new QueryContainer[7];
//Size is based on hte number of search parameters..
var descriptor = new QueryContainerDescriptor<EsNoteModel>();
var filters = new QueryContainer[1];
var filterdescriptor = new QueryContainerDescriptor<EsNoteModel>();
/*...... some code for other parameters here .....*/
if (hasFollowUpDate.HasValue)
{
if ((bool) hasFollowUpDate)
{
//If true shows only with a non-blank follow-up date
filters[0] = filterdescriptor.Exists(ff => ff.Field("FollowUpDateTime"));
}
else
{
//If false shows only notes with a blank follow-up date
filters[0] = filterdescriptor.Missing(ff => ff.Field("FollowUpDateTime"));
}
}
/*...... CALL to ES below .....*/
var result = ElasticSearchClient.Search<EsNoteModel>(body => body
.From(offset - 1)
.Size(rows)
.Query(q => q
.Bool(b => b
.Must(containers)
.Filter(f => f.Bool(t => t.Must(filters)))
)
)
.Sort(s => s
.Field(f => f
.Field(p => p.NoteDate)
.Order(SortOrder.Descending)))
);
嵌套:QueryParsingException[[customernote]bool查询不支持[filter]];您可以使用
QueryContainer
或FilterContainer
动态执行此操作。下面是我们解决方案中非常类似的一个:
var containers = new QueryContainer[7];
//Size is based on hte number of search parameters..
var descriptor = new QueryContainerDescriptor<EsNoteModel>();
var filters = new QueryContainer[1];
var filterdescriptor = new QueryContainerDescriptor<EsNoteModel>();
/*...... some code for other parameters here .....*/
if (hasFollowUpDate.HasValue)
{
if ((bool) hasFollowUpDate)
{
//If true shows only with a non-blank follow-up date
filters[0] = filterdescriptor.Exists(ff => ff.Field("FollowUpDateTime"));
}
else
{
//If false shows only notes with a blank follow-up date
filters[0] = filterdescriptor.Missing(ff => ff.Field("FollowUpDateTime"));
}
}
/*...... CALL to ES below .....*/
var result = ElasticSearchClient.Search<EsNoteModel>(body => body
.From(offset - 1)
.Size(rows)
.Query(q => q
.Bool(b => b
.Must(containers)
.Filter(f => f.Bool(t => t.Must(filters)))
)
)
.Sort(s => s
.Field(f => f
.Field(p => p.NoteDate)
.Order(SortOrder.Descending)))
);
var query = new List<QueryContainer>
{
Query<AlertForReporting>.Range(r => r.OnField(f => f.AlertDate)
.Greater(start.ToEPCISFormat())
.Lower(end.ToEPCISFormat())
)
};
var result = ElasticClient.Search<AlertForReporting>(s =>
s.Size(0)
.Query(q =>
q.Bool(b =>
b.Must(query.ToArray())
)
));
var query=新列表
{
Query.Range(r=>r.OnField(f=>f.AlertDate)
.greer(start.ToEPCISFormat())
.Lower(end.ToEPCISFormat())
)
};
var result=ElasticClient.Search(s=>
s、 大小(0)
.Query(q=>
q、 布尔(b=>
b、 必须(query.ToArray())
)
));
显然,我们在.NET 4.0项目中有以下参考
var containers = new QueryContainer[7];
//Size is based on hte number of search parameters..
var descriptor = new QueryContainerDescriptor<EsNoteModel>();
var filters = new QueryContainer[1];
var filterdescriptor = new QueryContainerDescriptor<EsNoteModel>();
/*...... some code for other parameters here .....*/
if (hasFollowUpDate.HasValue)
{
if ((bool) hasFollowUpDate)
{
//If true shows only with a non-blank follow-up date
filters[0] = filterdescriptor.Exists(ff => ff.Field("FollowUpDateTime"));
}
else
{
//If false shows only notes with a blank follow-up date
filters[0] = filterdescriptor.Missing(ff => ff.Field("FollowUpDateTime"));
}
}
/*...... CALL to ES below .....*/
var result = ElasticSearchClient.Search<EsNoteModel>(body => body
.From(offset - 1)
.Size(rows)
.Query(q => q
.Bool(b => b
.Must(containers)
.Filter(f => f.Bool(t => t.Must(filters)))
)
)
.Sort(s => s
.Field(f => f
.Field(p => p.NoteDate)
.Order(SortOrder.Descending)))
);