use of io.lumeer.api.model.QueryStem in project engine by Lumeer.
the class SearchFacadeIT method testSearchDocumentsByCollectionIds.
@Test
public void testSearchDocumentsByCollectionIds() {
String id1 = createDocument(collectionIds.get(0), "doc1").getId();
String id2 = createDocument(collectionIds.get(0), "doc2").getId();
createDocument(collectionIds.get(1), "doc3");
createDocument(collectionIds.get(1), "doc4");
String id5 = createDocument(collectionIds.get(2), "doc5").getId();
String id6 = createDocument(collectionIds.get(2), "doc6").getId();
QueryStem stem1 = new QueryStem(collectionIds.get(0));
QueryStem stem2 = new QueryStem(collectionIds.get(2));
Query query = new Query(Arrays.asList(stem1, stem2));
List<Document> documents = searchFacade.searchDocuments(query, true);
assertThat(documents).extracting(Document::getId).containsOnly(id1, id2, id5, id6);
}
use of io.lumeer.api.model.QueryStem in project engine by Lumeer.
the class SearchFacadeIT method testSearchDocumentsWithLinks.
@Test
public void testSearchDocumentsWithLinks() {
String id1 = createDocument(collectionIds.get(0), "lumeer lol").getId();
String id2 = createDocument(collectionIds.get(0), "lol").getId();
String id3 = createDocument(collectionIds.get(0), "lmr").getId();
String id4 = createDocument(collectionIds.get(0), "lalamr").getId();
String id5 = createDocument(collectionIds.get(0), "something fulltext").getId();
String id6 = createDocument(collectionIds.get(1), "lmr").getId();
String id7 = createDocument(collectionIds.get(1), "other lol").getId();
String id8 = createDocument(collectionIds.get(1), "o lmr").getId();
String id9 = createDocument(collectionIds.get(1), "lumeer").getId();
String id10 = createDocument(collectionIds.get(2), "mr").getId();
String id11 = createDocument(collectionIds.get(2), "mr lumr").getId();
String id12 = createDocument(collectionIds.get(2), "lol").getId();
String linkType01Id = linkTypeDao.createLinkType(new LinkType("lmr", Arrays.asList(collectionIds.get(0), collectionIds.get(1)), Collections.emptyList(), null, null, null)).getId();
String linkType12Id = linkTypeDao.createLinkType(new LinkType("lmrr", Arrays.asList(collectionIds.get(1), collectionIds.get(2)), Collections.emptyList(), null, null, null)).getId();
createLinkInstance(linkType01Id, Arrays.asList(id1, id6));
createLinkInstance(linkType01Id, Arrays.asList(id1, id7));
createLinkInstance(linkType01Id, Arrays.asList(id2, id8));
createLinkInstance(linkType01Id, Arrays.asList(id3, id8));
createLinkInstance(linkType01Id, Arrays.asList(id4, id6));
createLinkInstance(linkType12Id, Arrays.asList(id6, id10));
createLinkInstance(linkType12Id, Arrays.asList(id6, id11));
createLinkInstance(linkType12Id, Arrays.asList(id7, id12));
QueryStem stem = new QueryStem(null, collectionIds.get(0), Arrays.asList(linkType01Id, linkType12Id), Collections.emptySet(), Collections.emptyList(), Collections.emptyList());
Query query = new Query(Collections.singletonList(stem), Collections.emptySet(), null, null);
List<Document> documents = searchFacade.searchDocuments(query, true);
assertThat(documents).extracting(Document::getId).containsOnly(id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12);
stem = new QueryStem(null, collectionIds.get(0), Collections.singletonList(linkType01Id), Collections.emptySet(), Collections.emptyList(), Collections.emptyList());
query = new Query(Collections.singletonList(stem), Collections.singleton("lol"), null, null);
documents = searchFacade.searchDocuments(query, true);
assertThat(documents).extracting(Document::getId).containsOnly(id1, id2, id6, id7, id8);
stem = new QueryStem(null, collectionIds.get(1), Collections.singletonList(linkType12Id), Collections.emptySet(), Collections.emptyList(), Collections.emptyList());
query = new Query(Collections.singletonList(stem), Collections.singleton("lumr"), null, null);
documents = searchFacade.searchDocuments(query, true);
assertThat(documents).extracting(Document::getId).containsOnly(id11, id6);
}
use of io.lumeer.api.model.QueryStem in project engine by Lumeer.
the class SearchFacadeIT method testCyclicChildDocuments.
@Test
public void testCyclicChildDocuments() {
final Document a0 = createDocument(collectionIds.get(0), "a0");
final Document a1 = createDocument(collectionIds.get(0), "a1", a0.getId());
final Document a2 = createDocument(collectionIds.get(0), "a2", a1.getId());
a0.setMetaData(new DataDocument(Document.META_PARENT_ID, a2.getId()));
documentDao.updateDocument(a0.getId(), a0);
Query query = new Query(new QueryStem(null, collectionIds.get(0), Collections.emptyList(), Collections.singleton(a0.getId()), Collections.emptyList(), Collections.emptyList()));
List<Document> documents = searchFacade.searchDocuments(query, true);
assertThat(documents).hasSize(3);
var parents = documents.stream().map(d -> d.getMetaData().getString(Document.META_PARENT_ID)).collect(Collectors.toList());
var ids = documents.stream().map(Document::getId).collect(Collectors.toList());
assertThat(ids).hasSize(3);
assertThat(parents).hasSize(3);
assertThat(parents).containsAll(ids);
}
use of io.lumeer.api.model.QueryStem in project engine by Lumeer.
the class SearchFacadeIT method testSearchLinkInstances.
@Test
public void testSearchLinkInstances() {
LinkType linkType = new LinkType("nm", Arrays.asList(collectionIds.get(0), collectionIds.get(1)), Collections.emptyList(), null, null, null);
String linkTypeId1 = linkTypeDao.createLinkType(linkType).getId();
LinkType linkType2 = new LinkType("nm2", Arrays.asList(collectionIds.get(0), collectionIds.get(1)), Collections.emptyList(), null, null, null);
String linkTypeId2 = linkTypeDao.createLinkType(linkType2).getId();
String id10 = createDocument(collectionIds.get(0), "lumeer").getId();
String id11 = createDocument(collectionIds.get(0), "lumeer").getId();
String id12 = createDocument(collectionIds.get(0), "lumeer").getId();
String id20 = createDocument(collectionIds.get(1), "lumeer").getId();
String id21 = createDocument(collectionIds.get(1), "lumeer").getId();
String id22 = createDocument(collectionIds.get(1), "lumeer").getId();
String id1 = createLinkInstance(linkTypeId1, Arrays.asList(id10, id20)).getId();
String id2 = createLinkInstance(linkTypeId1, Arrays.asList(id10, id22)).getId();
String id3 = createLinkInstance(linkTypeId1, Arrays.asList(id11, id21)).getId();
String id4 = createLinkInstance(linkTypeId2, Arrays.asList(id10, id20)).getId();
QueryStem stem1 = new QueryStem(null, collectionIds.get(0), Collections.singletonList(linkTypeId1), Collections.singleton(id10), null, null);
Query query1 = new Query(stem1);
List<LinkInstance> linkInstances = searchFacade.searchLinkInstances(query1, true);
assertThat(linkInstances).extracting(LinkInstance::getId).containsOnly(id1, id2);
QueryStem stem2 = new QueryStem(null, collectionIds.get(1), Collections.singletonList(linkTypeId1), Collections.singleton(id21), null, null);
Query query = new Query(stem2);
linkInstances = searchFacade.searchLinkInstances(query, true);
assertThat(linkInstances).extracting(LinkInstance::getId).containsOnly(id3);
QueryStem stem3 = new QueryStem(null, collectionIds.get(0), Collections.singletonList(linkTypeId2), null, null, null);
Query query3 = new Query(stem3);
linkInstances = searchFacade.searchLinkInstances(query3, true);
assertThat(linkInstances).extracting(LinkInstance::getId).containsOnly(id4);
QueryStem stem4 = new QueryStem(null, collectionIds.get(0), Collections.singletonList(linkTypeId1), null, null, null);
Query query4 = new Query(stem4);
linkInstances = searchFacade.searchLinkInstances(query4, true);
assertThat(linkInstances).extracting(LinkInstance::getId).containsOnly(id1, id2, id3);
QueryStem stem5 = new QueryStem(null, collectionIds.get(0), Collections.singletonList(linkTypeId2), Collections.singleton(id20), null, null);
Query query5 = new Query(stem5);
linkInstances = searchFacade.searchLinkInstances(query5, true);
assertThat(linkInstances).extracting(LinkInstance::getId).containsOnly(id4);
}
use of io.lumeer.api.model.QueryStem in project engine by Lumeer.
the class SearchFacadeIT method testSearchDocumentsByIds.
@Test
public void testSearchDocumentsByIds() {
String id1 = createDocument(collectionIds.get(0), "doc1").getId();
createDocument(collectionIds.get(0), "doc2");
String id3 = createDocument(collectionIds.get(1), "doc3").getId();
String id4 = createDocument(collectionIds.get(1), "doc4").getId();
createDocument(collectionIds.get(2), "doc5");
String id6 = createDocument(collectionIds.get(2), "doc6").getId();
QueryStem stem1 = new QueryStem(null, collectionIds.get(0), Collections.emptyList(), Collections.singleton(id1), Collections.emptyList(), Collections.emptyList());
QueryStem stem2 = new QueryStem(null, collectionIds.get(1), Collections.emptyList(), new HashSet<>(Arrays.asList(id3, id4)), Collections.emptyList(), Collections.emptyList());
QueryStem stem3 = new QueryStem(null, collectionIds.get(2), Collections.emptyList(), Collections.singleton(id6), Collections.emptyList(), Collections.emptyList());
Query query = new Query(Arrays.asList(stem1, stem2, stem3));
List<Document> documents = searchFacade.searchDocuments(query, true);
assertThat(documents).extracting(Document::getId).containsOnly(id1, id3, id4, id6);
}
Aggregations