List of usage examples for org.apache.solr.common.params HighlightParams TAG_PRE
String TAG_PRE
To view the source code for org.apache.solr.common.params HighlightParams TAG_PRE.
Click Source Link
From source file:com.frank.search.solr.repository.query.AbstractSolrQuery.java
License:Apache License
private void appendHighlightFormatOptions(HighlightOptions options, SolrQueryMethod queryMethod) { String formatter = queryMethod.getHighlightFormatter(); if (formatter != null) { options.setFormatter(formatter); }//from w ww . j a v a 2 s . c o m String highlightPrefix = queryMethod.getHighlightPrefix(); if (highlightPrefix != null) { if (isSimpleHighlightingOption(formatter)) { options.setSimplePrefix(highlightPrefix); } else { options.addHighlightParameter(new HighlightParameter(HighlightParams.TAG_PRE, highlightPrefix)); } } String highlightPostfix = queryMethod.getHighlightPostfix(); if (highlightPostfix != null) { if (isSimpleHighlightingOption(formatter)) { options.setSimplePostfix(highlightPostfix); } else { options.addHighlightParameter(new HighlightParameter(HighlightParams.TAG_POST, highlightPostfix)); } } }
From source file:org.springframework.data.solr.repository.query.SolrQueryTests.java
License:Apache License
@SuppressWarnings("unchecked") @Test//from w w w. j a v a 2 s . co m public void testQueryWithNonDefaultHighlightFormatter() { ArgumentCaptor<HighlightQuery> captor = ArgumentCaptor.forClass(HighlightQuery.class); createQueryForMethod("findAndApplyHighlightingWithNonDefaultFormatter", Pageable.class) .execute(new Object[] { new PageRequest(0, 10) }); Mockito.verify(solrOperationsMock, Mockito.times(1)).queryForHighlightPage(captor.capture(), (Class<ProductBean>) Matchers.any()); HighlightOptions capturedOptions = captor.getValue().getHighlightOptions(); Assert.assertNotNull(capturedOptions); Assert.assertNull(capturedOptions.getSimplePrefix()); Assert.assertNull(capturedOptions.getSimplePrefix()); Assert.assertNull(capturedOptions.getSimplePostfix()); Assert.assertEquals("postingshighlighter", capturedOptions.getFormatter()); Assert.assertEquals("{pre}", capturedOptions.getHighlightParameterValue(HighlightParams.TAG_PRE)); Assert.assertEquals("{post}", capturedOptions.getHighlightParameterValue(HighlightParams.TAG_POST)); }