List of usage examples for org.apache.solr.handler.clustering ClusteringParams ENGINE_NAME
String ENGINE_NAME
To view the source code for org.apache.solr.handler.clustering ClusteringParams ENGINE_NAME.
Click Source Link
From source file:com.doculibre.constellio.services.ClusteringServicesImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/* w w w . j a v a2s . c om*/ public List<SimpleOrderedMap<Object>> cluster(SimpleSearch simpleSearch, CollectionFacet facet, int start, int row, ConstellioUser user) { // String luceneQuery = simpleSearch.getLuceneQuery(); RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices(); String solrServerName = simpleSearch.getCollectionName(); RecordCollection collection = collectionServices.get(solrServerName); //Remarque useDismax est false car nous allons utiliser le type de requete "/clustering" // donc pas besoin d'ajouter les paramtres necessaires dismax SolrQuery query = SearchServicesImpl.toSolrQuery(simpleSearch, false, true, true); query.setRequestHandler("/clustering"); query.setParam(ClusteringComponent.COMPONENT_NAME, Boolean.TRUE); query.setParam(ClusteringParams.USE_COLLECTION, facet.isClusteringUseCollection()); query.setParam(ClusteringParams.USE_SEARCH_RESULTS, facet.isClusteringUseSearchResults()); query.setParam(ClusteringParams.USE_DOC_SET, facet.isClusteringUseDocSet()); query.setParam(ClusteringParams.ENGINE_NAME, facet.getClusteringEngine()); //The maximum number of labels to produce query.setParam(CarrotParams.NUM_DESCRIPTIONS, "" + maxClusters); // query.setParam(CarrotParams.NUM_DESCRIPTIONS, "" + facet.getCarrotNumDescriptions()); query.setParam(CarrotParams.OUTPUT_SUB_CLUSTERS, facet.isCarrotOutputSubclusters()); query.setParam(ConstellioSolrQueryParams.LUCENE_QUERY, simpleSearch.getLuceneQuery()); query.setParam(ConstellioSolrQueryParams.COLLECTION_NAME, simpleSearch.getCollectionName()); query.setParam(ConstellioSolrQueryParams.SIMPLE_SEARCH, simpleSearch.toSimpleParams().toString()); if (user != null) { query.setParam(ConstellioSolrQueryParams.USER_ID, "" + user.getId()); } //If true, then the snippet field (if no snippet field, then the title field) will be highlighted and the highlighted text will be used for the snippet. query.setParam(CarrotParams.PRODUCE_SUMMARY, facet.isCarrotProduceSummary()); if (facet.getCarrotTitleField() != null) { IndexField indexField = facet.getCarrotTitleField(); query.setParam(CarrotParams.TITLE_FIELD_NAME, indexField.getName()); } if (facet.getCarrotUrlField() != null) { IndexField indexField = facet.getCarrotUrlField(); query.setParam(CarrotParams.URL_FIELD_NAME, indexField.getName()); } if (facet.getCarrotSnippetField() != null) { IndexField indexField = facet.getCarrotSnippetField(); query.setParam(CarrotParams.SNIPPET_FIELD_NAME, indexField.getName()); } // Requte Lucene // query.setQuery(luceneQuery); // nb rsultats par page query.setRows(row); // page de dbut query.setStart(start); //Les resultats ne vont pas etre affichs /*query.setHighlight(true); query.setHighlightFragsize(100); query.setHighlightSnippets(2);*/ if (collection.isOpenSearch()) { query.setParam("openSearchURL", collection.getOpenSearchURL()); } SolrServer server = SolrCoreContext.getSolrServer(solrServerName); QueryResponse queryResponse; try { queryResponse = server.query(query); } catch (SolrServerException e) { throw new RuntimeException(e); } NamedList<Object> values = queryResponse.getResponse(); Object clusters = values.get("clusters"); return (List<SimpleOrderedMap<Object>>) clusters; }