use of io.lumeer.storage.api.filter.CollectionSearchAttributeFilter in project engine by Lumeer.
the class MongoDataDaoTest method testSearchDataByAllConditions.
@Test
public void testSearchDataByAllConditions() {
Collection collection = collectionDao.getCollectionById(COLLECTION_ID);
String id1 = createDocument(KEY1, "lumeerko");
String id2 = createDocument(KEY2, "something lala");
String id3 = createDocument(KEY3, "lol nieco");
String id4 = createDocument(KEY2, "lumeerko");
CollectionSearchAttributeFilter filter = new CollectionSearchAttributeFilter(COLLECTION_ID, ConditionType.EQUALS, KEY1, "lumeerko");
SearchQueryStem stem = SearchQueryStem.createBuilder(COLLECTION_ID).filters(Collections.singleton(filter)).documentIds(new HashSet<>(Arrays.asList(id1, id2, id3, id4))).fulltexts(Collections.singleton("full")).build();
List<DataDocument> data = dataDao.searchData(stem, null, collection);
assertThat(data).extracting(DataDocument::getId).containsOnly(id1);
filter = new CollectionSearchAttributeFilter(COLLECTION_ID, ConditionType.EQUALS, KEY2, "lumeerko");
stem = SearchQueryStem.createBuilder(COLLECTION_ID).filters(Collections.singleton(filter)).documentIds(new HashSet<>(Arrays.asList(id1, id2, id3))).fulltexts(new HashSet<>(Arrays.asList("erko", "lumee"))).build();
data = dataDao.searchData(stem, null, collection);
assertThat(data).extracting(DataDocument::getId).isEmpty();
}
use of io.lumeer.storage.api.filter.CollectionSearchAttributeFilter in project engine by Lumeer.
the class MongoDataDaoTest method testSearchDataByFilters.
@Test
public void testSearchDataByFilters() {
Collection collection = collectionDao.getCollectionById(COLLECTION_ID);
String id1 = createDocument(KEY1, "4");
createDocument(KEY1, "8");
createDocument(KEY1, "13");
String id4 = createDocument(KEY1, "mama");
CollectionSearchAttributeFilter filter = new CollectionSearchAttributeFilter(COLLECTION_ID, ConditionType.EQUALS, KEY1, "4");
SearchQueryStem stem = SearchQueryStem.createBuilder(COLLECTION_ID).filters(Collections.singleton(filter)).build();
List<DataDocument> data = dataDao.searchData(stem, null, collection);
assertThat(data).extracting(DataDocument::getId).containsOnly(id1);
filter = new CollectionSearchAttributeFilter(COLLECTION_ID, ConditionType.EQUALS, KEY1, "mama");
stem = SearchQueryStem.createBuilder(COLLECTION_ID).filters(Collections.singleton(filter)).build();
data = dataDao.searchData(stem, null, collection);
assertThat(data).extracting(DataDocument::getId).containsOnly(id4);
}
Aggregations