use of org.alfresco.service.cmr.search.FieldHighlightParameters 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());
}
use of org.alfresco.service.cmr.search.FieldHighlightParameters 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);
}
use of org.alfresco.service.cmr.search.FieldHighlightParameters in project alfresco-remote-api by Alfresco.
the class SearchQuerySerializerTests method testDeserializeQuery.
@Test
public void testDeserializeQuery() throws IOException {
SearchQuery searchQuery = helper.searchQueryFromJson();
assertEquals(SearchQuery.class, searchQuery.getClass());
assertEquals("afts", searchQuery.getQuery().getLanguage());
assertEquals("g*", searchQuery.getQuery().getQuery());
assertEquals("great", searchQuery.getQuery().getUserQuery());
assertEquals(99, searchQuery.getPaging().getMaxItems());
assertEquals(4, searchQuery.getPaging().getSkipCount());
assertEquals(2, searchQuery.getInclude().size());
assertTrue(searchQuery.getInclude().contains("aspectNames"));
assertTrue(searchQuery.getInclude().contains("properties"));
assertEquals(1, searchQuery.getSort().size());
assertEquals(2, searchQuery.getTemplates().size());
Default defaults = searchQuery.getDefaults();
assertEquals("namesp", defaults.getNamespace());
assertEquals("myfield", defaults.getDefaultFieldName());
assertEquals("AND", defaults.getDefaultFTSOperator());
assertEquals(2, defaults.getTextAttributes().size());
assertTrue(defaults.getTextAttributes().contains("roy"));
assertTrue(defaults.getTextAttributes().contains("king"));
assertEquals(2, searchQuery.getFilterQueries().size());
assertEquals("myquery", searchQuery.getFilterQueries().get(0).getQuery());
assertEquals(2, searchQuery.getFilterQueries().get(0).getTags().size());
assertEquals("myquery2", searchQuery.getFilterQueries().get(1).getQuery());
assertEquals(1, searchQuery.getFacetQueries().size());
assertEquals("cm:created:bob", searchQuery.getFacetQueries().get(0).getQuery());
assertEquals("small", searchQuery.getFacetQueries().get(0).getLabel());
assertEquals("alfrezco", searchQuery.getSpellcheck().getQuery());
assertEquals(1, searchQuery.getScope().getLocations().size());
assertEquals(StoreMapper.LIVE_NODES, searchQuery.getScope().getLocations().get(0));
assertEquals(3, searchQuery.getFacetFields().getFacets().size());
FacetField ff = searchQuery.getFacetFields().getFacets().get(0);
assertEquals("cm:creator", ff.getField());
assertEquals("myquery2", ff.getPrefix());
assertEquals("COUNT", ff.getSort());
assertEquals(false, ff.getMissing());
ff = searchQuery.getFacetFields().getFacets().get(1);
assertEquals("modifier", ff.getField());
assertEquals("mylabel", ff.getLabel());
assertEquals("FC", ff.getMethod());
assertEquals(Integer.valueOf(5), ff.getMincount());
assertEquals(2000, searchQuery.getLimits().getPermissionEvaluationCount().intValue());
assertEquals(5000, searchQuery.getLimits().getPermissionEvaluationTime().intValue());
assertEquals(2, searchQuery.getFields().size());
assertTrue(searchQuery.getFields().contains("id"));
assertTrue(searchQuery.getFields().contains("name"));
// Highlight
assertEquals("]", searchQuery.getHighlight().getPostfix());
assertEquals("[", searchQuery.getHighlight().getPrefix());
assertEquals(20, searchQuery.getHighlight().getSnippetCount().intValue());
assertEquals(10, searchQuery.getHighlight().getFragmentSize().intValue());
assertEquals(true, searchQuery.getHighlight().getMergeContiguous());
assertEquals(40, searchQuery.getHighlight().getMaxAnalyzedChars().intValue());
assertEquals(true, searchQuery.getHighlight().getUsePhraseHighlighter());
assertEquals(2, searchQuery.getHighlight().getFields().size());
FieldHighlightParameters high1 = searchQuery.getHighlight().getFields().get(0);
assertEquals("my", high1.getField());
assertEquals("¡", high1.getPostfix());
assertEquals("?", high1.getPrefix());
assertEquals(23, high1.getSnippetCount().intValue());
assertEquals(5, high1.getFragmentSize().intValue());
assertEquals(true, high1.getMergeContiguous());
FieldHighlightParameters high2 = searchQuery.getHighlight().getFields().get(1);
assertEquals("your", high2.getField());
assertEquals(")", high2.getPostfix());
assertEquals("(", high2.getPrefix());
assertEquals(3, high2.getSnippetCount().intValue());
assertEquals(15, high2.getFragmentSize().intValue());
assertEquals(false, high2.getMergeContiguous());
// Facet intervals
IntervalParameters ip = searchQuery.getFacetIntervals();
assertNotNull(ip);
assertEquals(1, ip.getSets().size());
IntervalSet expected = new IntervalSet("1", "2", "king", true, false);
assertTrue(ip.getSets().contains(expected));
assertEquals(2, ip.getIntervals().size());
Interval interval = ip.getIntervals().get(0);
assertEquals("creator", interval.getLabel());
assertEquals("cm:creator", interval.getField());
expected = new IntervalSet("a", "b", "last", false, true);
assertTrue(interval.getSets().contains(expected));
assertEquals(1, searchQuery.getPivots().size());
assertEquals("mylabel", searchQuery.getPivots().get(0).getKey());
assertEquals(1, searchQuery.getStats().size());
assertEquals("cm:creator", searchQuery.getStats().get(0).getField());
assertEquals("mylabel", searchQuery.getStats().get(0).getLabel());
// Range Facet
List<RangeParameters> ranges = searchQuery.getFacetRanges();
assertNotNull(ranges);
}
Aggregations