Search in sources :

Example 6 with JsonQuery

use of io.lumeer.api.dto.JsonQuery in project engine by Lumeer.

the class SearchFacadeIT method testSearchCollectionsByDocumentsFullText.

@Test
public void testSearchCollectionsByDocumentsFullText() {
    createDocument(collectionIds.get(0), "word");
    createDocument(collectionIds.get(0), "fulltext");
    createDocument(collectionIds.get(1), "something fulltext");
    createDocument(collectionIds.get(1), "some other word");
    createDocument(collectionIds.get(2), "full word");
    List<Collection> collections = searchFacade.searchCollections(new JsonQuery("fulltext"));
    assertThat(collections).extracting(Collection::getId).containsOnly(collectionIds.get(0), collectionIds.get(1));
    collections = searchFacade.searchCollections(new JsonQuery("word"));
    assertThat(collections).extracting(Collection::getId).containsOnlyElementsOf(collectionIds);
}
Also used : JsonQuery(io.lumeer.api.dto.JsonQuery) JsonCollection(io.lumeer.api.dto.JsonCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Example 7 with JsonQuery

use of io.lumeer.api.dto.JsonQuery in project engine by Lumeer.

the class SearchFacadeIT method testSearchCollectionsCombination.

@Test
public void testSearchCollectionsCombination() {
    createDocument(collectionIds.get(0), "word").getId();
    String id2 = createDocument(collectionIds.get(0), "fulltext").getId();
    String id3 = createDocument(collectionIds.get(1), "something fulltext").getId();
    createDocument(collectionIds.get(1), "some other word").getId();
    String id5 = createDocument(collectionIds.get(2), "full word").getId();
    List<Collection> collections = searchFacade.searchCollections(new JsonQuery(Collections.singleton(collectionIds.get(0)), null, Collections.singleton(id3)));
    assertThat(collections).extracting(Collection::getId).containsOnly(collectionIds.get(0), collectionIds.get(1));
}
Also used : JsonQuery(io.lumeer.api.dto.JsonQuery) JsonCollection(io.lumeer.api.dto.JsonCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Example 8 with JsonQuery

use of io.lumeer.api.dto.JsonQuery in project engine by Lumeer.

the class SearchFacadeIT method testSearchDocumentsByEmptyQuery.

@Test
public void testSearchDocumentsByEmptyQuery() {
    String id1 = createDocument(collectionIds.get(0), "doc1").getId();
    String id2 = createDocument(collectionIds.get(0), "doc2").getId();
    String id3 = createDocument(collectionIds.get(1), "doc3").getId();
    String id4 = createDocument(collectionIds.get(1), "doc4").getId();
    String id5 = createDocument(collectionIds.get(2), "doc5").getId();
    String id6 = createDocument(collectionIds.get(2), "doc6").getId();
    List<Document> documents = searchFacade.searchDocuments(new JsonQuery());
    assertThat(documents).extracting(Document::getId).containsOnly(id1, id2, id3, id4, id5, id6);
}
Also used : JsonQuery(io.lumeer.api.dto.JsonQuery) DataDocument(io.lumeer.engine.api.data.DataDocument) JsonDocument(io.lumeer.api.dto.JsonDocument) Document(io.lumeer.api.model.Document) Test(org.junit.Test)

Example 9 with JsonQuery

use of io.lumeer.api.dto.JsonQuery in project engine by Lumeer.

the class SearchFacadeIT method testSearchCollectionsByDocumentsIds.

@Test
public void testSearchCollectionsByDocumentsIds() {
    String id1 = createDocument(collectionIds.get(0), "doc1").getId();
    String id2 = createDocument(collectionIds.get(0), "doc2").getId();
    String id3 = createDocument(collectionIds.get(1), "doc3").getId();
    String id4 = createDocument(collectionIds.get(1), "doc4").getId();
    String id5 = createDocument(collectionIds.get(2), "doc5").getId();
    String id6 = createDocument(collectionIds.get(2), "doc6").getId();
    List<Collection> collections = searchFacade.searchCollections(new JsonQuery(null, null, new HashSet<>(Arrays.asList(id1, id2, id3))));
    assertThat(collections).extracting(Collection::getId).containsOnly(collectionIds.get(0), collectionIds.get(1));
    collections = searchFacade.searchCollections(new JsonQuery(null, null, new HashSet<>(Arrays.asList(id1, id4, id5))));
    assertThat(collections).extracting(Collection::getId).containsOnlyElementsOf(collectionIds);
    collections = searchFacade.searchCollections(new JsonQuery(null, null, new HashSet<>(Arrays.asList(id5, id6))));
    assertThat(collections).extracting(Collection::getId).containsOnly(collectionIds.get(2));
}
Also used : JsonQuery(io.lumeer.api.dto.JsonQuery) JsonCollection(io.lumeer.api.dto.JsonCollection) Collection(io.lumeer.api.model.Collection) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 10 with JsonQuery

use of io.lumeer.api.dto.JsonQuery in project engine by Lumeer.

the class SearchFacadeIT method testSearchDocumentsByCombination.

@Test
public void testSearchDocumentsByCombination() {
    createDocument(collectionIds.get(0), "word");
    createDocument(collectionIds.get(0), "fulltext");
    createDocument(collectionIds.get(1), "something fulltext");
    createDocument(collectionIds.get(1), "some other word anything");
    createDocument(collectionIds.get(2), "full word");
    createDocument(collectionIds.get(2), "anything");
    List<Document> documents = searchFacade.searchDocuments(new JsonQuery(null, Collections.singleton(collectionIds.get(0)), null, null, "anything", null, null));
    assertThat(documents).extracting(Document::getId).isEmpty();
}
Also used : JsonQuery(io.lumeer.api.dto.JsonQuery) DataDocument(io.lumeer.engine.api.data.DataDocument) JsonDocument(io.lumeer.api.dto.JsonDocument) Document(io.lumeer.api.model.Document) Test(org.junit.Test)

Aggregations

JsonQuery (io.lumeer.api.dto.JsonQuery)18 Test (org.junit.Test)16 JsonCollection (io.lumeer.api.dto.JsonCollection)5 JsonDocument (io.lumeer.api.dto.JsonDocument)5 Collection (io.lumeer.api.model.Collection)5 Document (io.lumeer.api.model.Document)5 DataDocument (io.lumeer.engine.api.data.DataDocument)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 List (java.util.List)4 Entity (javax.ws.rs.client.Entity)4 Response (javax.ws.rs.core.Response)4 LinkInstance (io.lumeer.api.model.LinkInstance)3 LinkType (io.lumeer.api.model.LinkType)3 JsonView (io.lumeer.api.dto.JsonView)2 GenericType (javax.ws.rs.core.GenericType)2 JsonPermissions (io.lumeer.api.dto.JsonPermissions)1 Document (org.bson.Document)1