use of com.couchbase.client.java.search.SearchQuery in project jnosql-diana-driver by eclipse.
the class SearchQueryTest method shouldSearchElement3.
@Test
public void shouldSearchElement3() {
MatchQuery match = SearchQuery.match("Salvador").field("name");
SearchQuery query = new SearchQuery("index-diana", match);
List<DocumentEntity> entities = entityManager.search(query);
assertEquals(1, entities.size());
List<String> result = entities.stream().flatMap(e -> e.getDocuments().stream()).filter(d -> "name".equals(d.getName())).map(d -> d.get(String.class)).collect(Collectors.toList());
assertThat(result, containsInAnyOrder("Salvador"));
}
use of com.couchbase.client.java.search.SearchQuery in project jnosql-diana-driver by eclipse.
the class SearchQueryTest method shouldSearchElement2.
@Test
public void shouldSearchElement2() {
MatchQuery match = SearchQuery.match("Brazil");
SearchQuery query = new SearchQuery("index-diana", match);
List<DocumentEntity> entities = entityManager.search(query);
assertEquals(3, entities.size());
List<String> result = entities.stream().flatMap(e -> e.getDocuments().stream()).filter(d -> "name".equals(d.getName())).map(d -> d.get(String.class)).collect(Collectors.toList());
assertThat(result, containsInAnyOrder("Salvador", "Rio de Janeiro", "Manaus"));
}
use of com.couchbase.client.java.search.SearchQuery in project jnosql-diana-driver by eclipse.
the class SearchQueryTest method shouldSearchElement.
@Test
public void shouldSearchElement() {
MatchQuery match = SearchQuery.match("Financial");
SearchQuery query = new SearchQuery("index-diana", match);
List<DocumentEntity> entities = entityManager.search(query);
assertEquals(1, entities.size());
assertEquals(Document.of("name", "São Paulo"), entities.get(0).find("name").get());
}
Aggregations