@@ -252,10 +252,18 @@ private Query convertTextCriterion(SearchQuery.TextCriterion textCriterion) {
252252 }
253253 case FULL :
254254 if (useQueryStringQuery && QUERY_STRING_CONTROL_CHAR .matchesAnyOf (textCriterion .getOperator ().getValue ())) {
255- return new SimpleQueryStringQuery .Builder ()
256- .fields (ImmutableList .of (JsonMessageConstants .TEXT_BODY , JsonMessageConstants .HTML_BODY , JsonMessageConstants .ATTACHMENTS + "." + JsonMessageConstants .Attachment .TEXT_CONTENT ))
257- .query (textCriterion .getOperator ().getValue ())
258- .build ().toQuery ();
255+ return new BoolQuery .Builder ()
256+ .should (new SimpleQueryStringQuery .Builder ()
257+ .fields (ImmutableList .of (JsonMessageConstants .TEXT_BODY , JsonMessageConstants .HTML_BODY , JsonMessageConstants .ATTACHMENTS + "." + JsonMessageConstants .Attachment .TEXT_CONTENT ))
258+ .query (textCriterion .getOperator ().getValue ())
259+ .build ().toQuery ())
260+ .should (new TermQuery .Builder ()
261+ .field (JsonMessageConstants .ATTACHMENTS + "." + JsonMessageConstants .Attachment .FILE_EXTENSION )
262+ .value (new FieldValue .Builder ().stringValue (textCriterion .getOperator ().getValue ()).build ())
263+ .build ()
264+ .toQuery ())
265+ .build ()
266+ .toQuery ();
259267 } else {
260268 return new BoolQuery .Builder ()
261269 .should (new MatchQuery .Builder ()
@@ -279,15 +287,28 @@ private Query convertTextCriterion(SearchQuery.TextCriterion textCriterion) {
279287 .operator (Operator .And )
280288 .build ()
281289 .toQuery ())
290+ .should (new TermQuery .Builder ()
291+ .field (JsonMessageConstants .ATTACHMENTS + "." + JsonMessageConstants .Attachment .FILE_EXTENSION )
292+ .value (new FieldValue .Builder ().stringValue (textCriterion .getOperator ().getValue ()).build ())
293+ .build ()
294+ .toQuery ())
282295 .build ()
283296 .toQuery ();
284297 }
285298 case ATTACHMENTS :
286299 if (useQueryStringQuery ) {
287- return new SimpleQueryStringQuery .Builder ()
288- .fields (ImmutableList .of (JsonMessageConstants .ATTACHMENTS + "." + JsonMessageConstants .Attachment .TEXT_CONTENT ))
289- .query (textCriterion .getOperator ().getValue ())
290- .build ().toQuery ();
300+ return new BoolQuery .Builder ()
301+ .should (new SimpleQueryStringQuery .Builder ()
302+ .fields (ImmutableList .of (JsonMessageConstants .ATTACHMENTS + "." + JsonMessageConstants .Attachment .TEXT_CONTENT ))
303+ .query (textCriterion .getOperator ().getValue ())
304+ .build ().toQuery ())
305+ .should (new TermQuery .Builder ()
306+ .field (JsonMessageConstants .ATTACHMENTS + "." + JsonMessageConstants .Attachment .FILE_EXTENSION )
307+ .value (new FieldValue .Builder ().stringValue (textCriterion .getOperator ().getValue ()).build ())
308+ .build ()
309+ .toQuery ())
310+ .build ()
311+ .toQuery ();
291312 } else {
292313 return new BoolQuery .Builder ()
293314 .should (new MatchQuery .Builder ()
@@ -297,6 +318,11 @@ private Query convertTextCriterion(SearchQuery.TextCriterion textCriterion) {
297318 .operator (Operator .And )
298319 .build ()
299320 .toQuery ())
321+ .should (new TermQuery .Builder ()
322+ .field (JsonMessageConstants .ATTACHMENTS + "." + JsonMessageConstants .Attachment .FILE_EXTENSION )
323+ .value (new FieldValue .Builder ().stringValue (textCriterion .getOperator ().getValue ()).build ())
324+ .build ()
325+ .toQuery ())
300326 .build ()
301327 .toQuery ();
302328 }
@@ -309,6 +335,11 @@ private Query convertTextCriterion(SearchQuery.TextCriterion textCriterion) {
309335 .operator (Operator .And )
310336 .build ()
311337 .toQuery ())
338+ .should (new TermQuery .Builder ()
339+ .field (JsonMessageConstants .ATTACHMENTS + "." + JsonMessageConstants .Attachment .FILE_EXTENSION )
340+ .value (new FieldValue .Builder ().stringValue (textCriterion .getOperator ().getValue ()).build ())
341+ .build ()
342+ .toQuery ())
312343 .build ()
313344 .toQuery ();
314345 default :
0 commit comments