コード例 #1
0
  @Test
  public void createExistsFilter() throws Exception {
    final ExistsFilter queryFilter = ExistsFilter.create().fieldName("myField").build();

    final String expected = load("filter_exists.json");
    final FilterBuilder filterBuilder =
        new FilterBuilderFactory(new SearchQueryFieldNameResolver())
            .create(Filters.from(queryFilter));

    Assert.assertEquals(cleanString(expected), cleanString(filterBuilder.toString()));
  }
コード例 #2
0
  @Test
  public void createBooleanFilter() throws Exception {
    final BooleanFilter.Builder builder = BooleanFilter.create();

    builder.must(ExistsFilter.create().fieldName("MyMust").build());
    builder.must(ExistsFilter.create().fieldName("MyMust").build());
    builder.mustNot(ExistsFilter.create().fieldName("MyMustNot").build());
    builder.should(ExistsFilter.create().fieldName("MyOptional").build());
    builder.should(ExistsFilter.create().fieldName("MyOptional").build());
    builder.should(ExistsFilter.create().fieldName("MyOptional").build());

    final String expected = load("filter_boolean.json");
    final FilterBuilder filterBuilder =
        new FilterBuilderFactory(new SearchQueryFieldNameResolver())
            .create(Filters.from(builder.build()));

    Assert.assertEquals(cleanString(expected), cleanString(filterBuilder.toString()));
  }