use of org.apache.solr.handler.clustering.SearchClusteringEngine in project lucene-solr by apache.
the class CarrotClusteringEngineTest method testDeclarationEngineOrder.
@Test
public void testDeclarationEngineOrder() throws Exception {
ClusteringComponent comp = (ClusteringComponent) h.getCore().getSearchComponent("clustering-name-decl-order");
Map<String, SearchClusteringEngine> engines = getSearchClusteringEngines(comp);
assertEquals(Arrays.asList("unavailable", "lingo", "stc", "mock", "default"), new ArrayList<>(engines.keySet()));
assertEquals(LingoClusteringAlgorithm.class, ((CarrotClusteringEngine) engines.get(ClusteringEngine.DEFAULT_ENGINE_NAME)).getClusteringAlgorithmClass());
}
use of org.apache.solr.handler.clustering.SearchClusteringEngine in project SearchServices by Alfresco.
the class AlfrescoSolrClusteringComponent method process.
@Override
public void process(ResponseBuilder rb) throws IOException {
SolrParams params = rb.req.getParams();
if (!params.getBool(COMPONENT_NAME, false)) {
return;
}
final String name = getClusteringEngineName(rb);
boolean useResults = params.getBool(ClusteringParams.USE_SEARCH_RESULTS, false);
if (useResults == true) {
SearchClusteringEngine engine = searchClusteringEngines.get(name);
if (engine != null) {
checkAvailable(name, engine);
DocListAndSet results = rb.getResults();
Map<SolrDocument, Integer> docIds = Maps.newHashMapWithExpectedSize(results.docList.size());
SolrDocumentList solrDocList = docListToSolrDocumentList(results.docList, rb.req, docIds);
Object clusters = engine.cluster(rb.getQuery(), solrDocList, docIds, rb.req);
rb.rsp.add("clusters", clusters);
} else {
log.warn("No engine named: " + name);
}
}
boolean useCollection = params.getBool(ClusteringParams.USE_COLLECTION, false);
if (useCollection == true) {
DocumentClusteringEngine engine = documentClusteringEngines.get(name);
if (engine != null) {
checkAvailable(name, engine);
boolean useDocSet = params.getBool(ClusteringParams.USE_DOC_SET, false);
NamedList<?> nl = null;
// that runs in an executor
if (useDocSet == true) {
nl = engine.cluster(rb.getResults().docSet, params);
} else {
nl = engine.cluster(params);
}
rb.rsp.add("clusters", nl);
} else {
log.warn("No engine named: " + name);
}
}
}
use of org.apache.solr.handler.clustering.SearchClusteringEngine in project SearchServices by Alfresco.
the class AlfrescoSolrClusteringComponent method finishStage.
@Override
public void finishStage(ResponseBuilder rb) {
SolrParams params = rb.req.getParams();
if (!params.getBool(COMPONENT_NAME, false) || !params.getBool(ClusteringParams.USE_SEARCH_RESULTS, false)) {
return;
}
if (rb.stage == ResponseBuilder.STAGE_GET_FIELDS) {
String name = getClusteringEngineName(rb);
SearchClusteringEngine engine = searchClusteringEngines.get(name);
if (engine != null) {
checkAvailable(name, engine);
SolrDocumentList solrDocList = (SolrDocumentList) rb.rsp.getValues().get("response");
// TODO: Currently, docIds is set to null in distributed
// environment.
// This causes CarrotParams.PRODUCE_SUMMARY doesn't work.
// To work CarrotParams.PRODUCE_SUMMARY under distributed mode,
// we can choose either one of:
// (a) In each shard, ClusteringComponent produces summary and
// finishStage()
// merges these summaries.
// (b) Adding doHighlighting(SolrDocumentList, ...) method to
// SolrHighlighter and
// making SolrHighlighter uses "external text" rather than
// stored values to produce snippets.
Map<SolrDocument, Integer> docIds = null;
Object clusters = engine.cluster(rb.getQuery(), solrDocList, docIds, rb.req);
rb.rsp.add("clusters", clusters);
} else {
log.warn("No engine named: " + name);
}
}
}
use of org.apache.solr.handler.clustering.SearchClusteringEngine in project lucene-solr by apache.
the class CarrotClusteringEngineTest method testDeclarationNameDuplicates.
@Test
public void testDeclarationNameDuplicates() throws Exception {
ClusteringComponent comp = (ClusteringComponent) h.getCore().getSearchComponent("clustering-name-dups");
Map<String, SearchClusteringEngine> engines = getSearchClusteringEngines(comp);
assertEquals(Arrays.asList("", "default"), new ArrayList<>(engines.keySet()));
assertEquals(MockClusteringAlgorithm.class, ((CarrotClusteringEngine) engines.get(ClusteringEngine.DEFAULT_ENGINE_NAME)).getClusteringAlgorithmClass());
}
use of org.apache.solr.handler.clustering.SearchClusteringEngine in project lucene-solr by apache.
the class CarrotClusteringEngineTest method testDefaultEngineOrder.
@Test
public void testDefaultEngineOrder() throws Exception {
ClusteringComponent comp = (ClusteringComponent) h.getCore().getSearchComponent("clustering-name-default");
Map<String, SearchClusteringEngine> engines = getSearchClusteringEngines(comp);
assertEquals(Arrays.asList("stc", "default", "mock"), new ArrayList<>(engines.keySet()));
assertEquals(LingoClusteringAlgorithm.class, ((CarrotClusteringEngine) engines.get(ClusteringEngine.DEFAULT_ENGINE_NAME)).getClusteringAlgorithmClass());
}
Aggregations