Search in sources :

Example 1 with SearchEngineManager

use of org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager in project entando-core by entando.

the class TestSearchEngineManager method testSearchContentsId_4.

public void testSearchContentsId_4() throws Throwable {
    try {
        Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
        thread.join();
        SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
        SearchEngineFilter filterByType = new SearchEngineFilter(IIndexerDAO.DATAOBJECT_TYPE_FIELD_NAME, "ART");
        SearchEngineFilter[] filters = { filterByType };
        List<String> allowedGroup = new ArrayList<String>();
        allowedGroup.add(Group.FREE_GROUP_NAME);
        List<String> contentsId = sem.searchEntityId(filters, null, allowedGroup);
        assertNotNull(contentsId);
        String[] expected1 = { "ART180", "ART1", "ART187", "ART121" };
        this.verify(contentsId, expected1);
        Category cat1 = this._categoryManager.getCategory("cat1");
        List<ITreeNode> categories = new ArrayList<ITreeNode>();
        categories.add(cat1);
        contentsId = sem.searchEntityId(filters, categories, allowedGroup);
        assertNotNull(contentsId);
        String[] expected2 = { "ART180" };
        this.verify(contentsId, expected2);
    } catch (Throwable t) {
        throw t;
    }
}
Also used : SearchEngineFilter(org.entando.entando.aps.system.services.searchengine.SearchEngineFilter) Category(com.agiletec.aps.system.services.category.Category) ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode) IDataObjectSearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.IDataObjectSearchEngineManager) SearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager) ArrayList(java.util.ArrayList)

Example 2 with SearchEngineManager

use of org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager in project entando-core by entando.

the class TestSearchEngineManager method testSearchContentsId_6.

public void testSearchContentsId_6() throws Throwable {
    try {
        Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
        thread.join();
        SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
        Category general = this._categoryManager.getCategory("general");
        List<ITreeNode> categories = new ArrayList<ITreeNode>();
        categories.add(general);
        List<String> allowedGroup = new ArrayList<String>();
        allowedGroup.add(Group.ADMINS_GROUP_NAME);
        List<String> contentsId = sem.searchEntityId(null, categories, allowedGroup);
        assertNotNull(contentsId);
        String[] expected1 = { "ART122", "ART102", "ART111", "ART120" };
        this.verify(contentsId, expected1);
    } catch (Throwable t) {
        throw t;
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode) IDataObjectSearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.IDataObjectSearchEngineManager) SearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager) ArrayList(java.util.ArrayList)

Example 3 with SearchEngineManager

use of org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager in project entando-core by entando.

the class TestSearchEngineManager method testSearchFacetedContents_1.

public void testSearchFacetedContents_1() throws Throwable {
    try {
        Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
        thread.join();
        SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
        Category general = this._categoryManager.getCategory("general");
        List<ITreeNode> categories = new ArrayList<ITreeNode>();
        categories.add(general);
        List<String> allowedGroup = new ArrayList<String>();
        allowedGroup.add(Group.FREE_GROUP_NAME);
        allowedGroup.add(Group.ADMINS_GROUP_NAME);
        FacetedContentsResult result = sem.searchFacetedEntities(null, categories, allowedGroup);
        assertNotNull(result);
        String[] expected1 = { "ART122", "ART102", "ART111", "ART120" };
        this.verify(result.getContentsId(), expected1);
        assertEquals(4, result.getOccurrences().size());
    } catch (Throwable t) {
        throw t;
    }
}
Also used : FacetedContentsResult(org.entando.entando.aps.system.services.searchengine.FacetedContentsResult) Category(com.agiletec.aps.system.services.category.Category) ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode) IDataObjectSearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.IDataObjectSearchEngineManager) SearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager) ArrayList(java.util.ArrayList)

Example 4 with SearchEngineManager

use of org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager in project entando-core by entando.

the class TestSearchEngineManager method testSearchContentsId_5.

public void testSearchContentsId_5() throws Throwable {
    try {
        Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
        thread.join();
        SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
        Category general_cat2 = this._categoryManager.getCategory("general_cat2");
        List<ITreeNode> categories = new ArrayList<ITreeNode>();
        categories.add(general_cat2);
        List<String> allowedGroup = new ArrayList<String>();
        allowedGroup.add(Group.FREE_GROUP_NAME);
        List<String> contentsId = sem.searchEntityId(null, categories, allowedGroup);
        assertNotNull(contentsId);
        assertTrue(contentsId.isEmpty());
        allowedGroup.add(Group.ADMINS_GROUP_NAME);
        contentsId = sem.searchEntityId(null, categories, allowedGroup);
        String[] expected1 = { "ART111", "ART120" };
        this.verify(contentsId, expected1);
        Category general_cat1 = this._categoryManager.getCategory("general_cat1");
        categories.add(general_cat1);
        contentsId = sem.searchEntityId(null, categories, allowedGroup);
        assertNotNull(contentsId);
        String[] expected2 = { "ART111" };
        this.verify(contentsId, expected2);
    } catch (Throwable t) {
        throw t;
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode) IDataObjectSearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.IDataObjectSearchEngineManager) SearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager) ArrayList(java.util.ArrayList)

Example 5 with SearchEngineManager

use of org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager in project entando-core by entando.

the class TestSearchEngineManager method testSearchContentsId_7.

public void testSearchContentsId_7() throws Throwable {
    try {
        DataObject content_1 = this.createDataObject_1();
        this.dataObjectSearchEngineManager.deleteIndexedEntity(content_1.getId());
        this.dataObjectSearchEngineManager.addEntityToIndex(content_1);
        DataObject content_2 = this.createDataObject_2();
        this.dataObjectSearchEngineManager.deleteIndexedEntity(content_2.getId());
        this.dataObjectSearchEngineManager.addEntityToIndex(content_2);
        DataObject content_3 = this.createDataObject_3();
        this.dataObjectSearchEngineManager.deleteIndexedEntity(content_3.getId());
        this.dataObjectSearchEngineManager.addEntityToIndex(content_3);
        // San Pietroburgo è una città meravigliosa W3C-WAI
        // 100
        // Il turismo ha incrementato più del 20 per cento nel 2011-2013, quando la Croazia ha aderito all'Unione europea. Consegienda di questo aumento è una serie di modernizzazione di alloggi di recente costruzione, tra cui circa tre dozzine di ostelli.
        // 101
        // La vita è una cosa meravigliosa
        // 103
        SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
        List<String> allowedGroup = new ArrayList<String>();
        allowedGroup.add(Group.FREE_GROUP_NAME);
        SearchEngineFilter filter1 = new SearchEngineFilter("it", "San meravigliosa", SearchEngineFilter.TextSearchOption.ALL_WORDS);
        SearchEngineFilter[] filters1 = { filter1 };
        List<String> contentsId = sem.searchEntityId(filters1, null, allowedGroup);
        assertNotNull(contentsId);
        assertEquals(1, contentsId.size());
        assertTrue(contentsId.contains(content_1.getId()));
        SearchEngineFilter filter2 = new SearchEngineFilter("it", "San meravigliosa", SearchEngineFilter.TextSearchOption.AT_LEAST_ONE_WORD);
        SearchEngineFilter[] filters2 = { filter2 };
        contentsId = sem.searchEntityId(filters2, null, allowedGroup);
        assertNotNull(contentsId);
        assertEquals(2, contentsId.size());
        assertTrue(contentsId.contains(content_1.getId()));
        assertTrue(contentsId.contains(content_3.getId()));
        SearchEngineFilter filter3 = new SearchEngineFilter("it", "San meravigliosa", SearchEngineFilter.TextSearchOption.EXACT);
        SearchEngineFilter[] filters3 = { filter3 };
        contentsId = sem.searchEntityId(filters3, null, allowedGroup);
        assertNotNull(contentsId);
        assertEquals(0, contentsId.size());
        SearchEngineFilter filter4 = new SearchEngineFilter("it", "una cosa meravigliosa", SearchEngineFilter.TextSearchOption.EXACT);
        SearchEngineFilter[] filters4 = { filter4 };
        contentsId = sem.searchEntityId(filters4, null, allowedGroup);
        assertNotNull(contentsId);
        assertEquals(1, contentsId.size());
        assertTrue(contentsId.contains(content_3.getId()));
    } catch (Throwable t) {
        throw t;
    }
}
Also used : SearchEngineFilter(org.entando.entando.aps.system.services.searchengine.SearchEngineFilter) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) IDataObjectSearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.IDataObjectSearchEngineManager) SearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager) ArrayList(java.util.ArrayList)

Aggregations

IDataObjectSearchEngineManager (org.entando.entando.aps.system.services.dataobjectsearchengine.IDataObjectSearchEngineManager)7 SearchEngineManager (org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager)7 ArrayList (java.util.ArrayList)5 ITreeNode (com.agiletec.aps.system.common.tree.ITreeNode)4 Category (com.agiletec.aps.system.services.category.Category)4 SearchEngineFilter (org.entando.entando.aps.system.services.searchengine.SearchEngineFilter)4 HashSet (java.util.HashSet)2 FacetedContentsResult (org.entando.entando.aps.system.services.searchengine.FacetedContentsResult)2 DataObject (org.entando.entando.aps.system.services.dataobject.model.DataObject)1