use of org.apache.solr.handler.component.AlfrescoSolrHighlighter in project SearchServices by Alfresco.
the class AlfrescoHighligherDistributedTest method testHighlight.
@Test
public void testHighlight() throws Exception {
logger.info("######### Starting highlighter test ###########");
SolrCore defaultCore = jetty.getDefaultCore();
SolrHighlighter highlighter = HighlightComponent.getHighlighter(defaultCore);
assertTrue("wrong highlighter: " + highlighter.getClass(), highlighter instanceof AlfrescoSolrHighlighter);
/**
* AclChangeSet aclChangeSet = getAclChangeSet(1);
* Acl acl = getAcl(aclChangeSet);
*
* AclReaders aclReaders = getAclReaders(aclChangeSet, acl, list("mike"), list("mike"), null);
*
* indexAclChangeSet(aclChangeSet, list(acl), list(aclReaders));
*
* //First create a transaction.
* Transaction foldertxn = getTransaction(0, 1);
* Transaction txn = getTransaction(0, 2);
*
* //Next create two nodes to update for the transaction
* Node folderNode = getNode(foldertxn, acl, Node.SolrApiNodeStatus.UPDATED);
* Node fileNode = getNode(txn, acl, Node.SolrApiNodeStatus.UPDATED);
* Node fileNode2 = getNode(txn, acl, Node.SolrApiNodeStatus.UPDATED);
*
* NodeMetaData folderMetaData = getNodeMetaData(folderNode, foldertxn, acl, "mike", null, false);
* NodeMetaData fileMetaData = getNodeMetaData(fileNode, txn, acl, "mike", ancestors(folderMetaData.getNodeRef()), false);
* NodeMetaData fileMetaData2 = getNodeMetaData(fileNode2, txn, acl, "mike", ancestors(folderMetaData.getNodeRef()), false);
*
* fileMetaData.getProperties().put(ContentModel.PROP_NAME, new StringPropertyValue("some very long name"));
* fileMetaData.getProperties().put(ContentModel.PROP_TITLE, new StringPropertyValue("title1"));
* fileMetaData.getProperties().put(ContentModel.PROP_DESCRIPTION, new StringPropertyValue("mydesc"));
*
* fileMetaData2.getProperties().put(ContentModel.PROP_NAME, new StringPropertyValue("some name"));
* fileMetaData2.getProperties().put(ContentModel.PROP_TITLE, new StringPropertyValue("title2"));
*
* String LONG_TEXT = "this is some long text. It has the word long in many places. In fact, it has long on some different fragments. " +
* "Let us see what happens to long in this case.";
*
* List<String> content = Arrays.asList(LONG_TEXT, LONG_TEXT);
*
* //Index the transaction, nodes, and nodeMetaDatas.
* indexTransaction(foldertxn, list(folderNode), list(folderMetaData));
* indexTransaction(txn,
* list(fileNode, fileNode2),
* list(fileMetaData, fileMetaData2),
* content);
* logger.info("######### Waiting for Doc Count ###########");
* waitForDocCount(new TermQuery(new Term(QueryConstants.FIELD_OWNER, "mike")), 3, 80000);
* waitForDocCount(new TermQuery(new Term(ContentModel.PROP_TITLE.toString(), "title1")), 1, 500);
* waitForDocCount(new TermQuery(new Term(ContentModel.PROP_DESCRIPTION.toString(), "mydesc")), 1, 500);
*
* //name, title, description, content
* //up to 3 matches in the content (needs to be big enough)
* QueryResponse response = query(jetty.getDefaultClient(), false,
* "{\"locales\":[\"en\"], \"authorities\": [\"mike\"], \"tenants\": [ \"\" ]}",
* params( "q", ContentModel.PROP_NAME.toString()+":some very long name",
* "qt", "/afts", "start", "0", "rows", "5",
* HighlightParams.HIGHLIGHT, "true",
* HighlightParams.FIELDS, "",
* HighlightParams.SNIPPETS, String.valueOf(4),
* HighlightParams.FRAGSIZE, String.valueOf(40)));
*
* assertTrue(response.getResults().getNumFound() > 0);
*/
}
use of org.apache.solr.handler.component.AlfrescoSolrHighlighter in project SearchServices by Alfresco.
the class TestPostingsSolrHighlighter method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
initAlfrescoCore("schema.xml");
// test our config is sane, just to be sure:
// postingshighlighter should be used
SolrHighlighter highlighter = HighlightComponent.getHighlighter(h.getCore());
assertTrue("wrong highlighter: " + highlighter.getClass(), highlighter instanceof AlfrescoSolrHighlighter);
// 'text' and 'text3' should have offsets, 'text2' should not
IndexSchema schema = h.getCore().getLatestSchema();
assertTrue(schema.getField("text").storeOffsetsWithPositions());
assertTrue(schema.getField("text3").storeOffsetsWithPositions());
assertFalse(schema.getField("text2").storeOffsetsWithPositions());
}
Aggregations