Search in sources :

Example 1 with GeneralHighlightParameters

use of org.alfresco.service.cmr.search.GeneralHighlightParameters in project alfresco-remote-api by Alfresco.

the class ResultMapperTests method testHighlight.

@Test
public void testHighlight() throws Exception {
    SearchParameters sp = new SearchParameters();
    sp.setBulkFetchEnabled(false);
    GeneralHighlightParameters highlightParameters = new GeneralHighlightParameters(null, null, null, null, null, null, null, null);
    sp.setHighlight(highlightParameters);
    assertNull(sp.getHighlight().getMergeContiguous());
    assertNull(sp.getHighlight().getFields());
    List<FieldHighlightParameters> fields = new ArrayList<>(2);
    fields.add(new FieldHighlightParameters(null, null, null, null, null, null));
    fields.add(new FieldHighlightParameters("myfield", null, null, null, "(", ")"));
    highlightParameters = new GeneralHighlightParameters(1, 2, null, null, null, 50, true, fields);
    sp.setHighlight(highlightParameters);
    assertEquals(2, sp.getHighlight().getFields().size());
    assertEquals(true, sp.getHighlight().getUsePhraseHighlighter().booleanValue());
    assertEquals(1, sp.getHighlight().getSnippetCount().intValue());
    assertEquals(50, sp.getHighlight().getMaxAnalyzedChars().intValue());
    assertEquals(2, sp.getHighlight().getFragmentSize().intValue());
    assertEquals("myfield", sp.getHighlight().getFields().get(1).getField());
    assertEquals("(", sp.getHighlight().getFields().get(1).getPrefix());
    assertEquals(")", sp.getHighlight().getFields().get(1).getPostfix());
}
Also used : SearchParameters(org.alfresco.service.cmr.search.SearchParameters) ArrayList(java.util.ArrayList) FieldHighlightParameters(org.alfresco.service.cmr.search.FieldHighlightParameters) GeneralHighlightParameters(org.alfresco.service.cmr.search.GeneralHighlightParameters) Test(org.junit.Test)

Example 2 with GeneralHighlightParameters

use of org.alfresco.service.cmr.search.GeneralHighlightParameters in project alfresco-remote-api by Alfresco.

the class SearchMapperTests method fromHighlight.

@Test
public void fromHighlight() throws Exception {
    SearchParameters searchParameters = new SearchParameters();
    List<FieldHighlightParameters> fields = Arrays.asList(new FieldHighlightParameters("desc", 50, 100, false, "@", "#"), new FieldHighlightParameters("title", 55, 105, true, "*", "¿"));
    GeneralHighlightParameters highlightParameters = new GeneralHighlightParameters(5, 10, false, "{", "}", 20, true, fields);
    searchMapper.fromHighlight(searchParameters, highlightParameters);
    assertEquals(searchParameters.getHighlight(), highlightParameters);
}
Also used : SearchParameters(org.alfresco.service.cmr.search.SearchParameters) FieldHighlightParameters(org.alfresco.service.cmr.search.FieldHighlightParameters) GeneralHighlightParameters(org.alfresco.service.cmr.search.GeneralHighlightParameters) Test(org.junit.Test)

Aggregations

FieldHighlightParameters (org.alfresco.service.cmr.search.FieldHighlightParameters)2 GeneralHighlightParameters (org.alfresco.service.cmr.search.GeneralHighlightParameters)2 SearchParameters (org.alfresco.service.cmr.search.SearchParameters)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1