Java Code Examples for org.apache.solr.search.SolrIndexSearcher#close()
The following examples show how to use
org.apache.solr.search.SolrIndexSearcher#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppBasic.java From jate with GNU Lesser General Public License v3.0 | 5 votes |
public List<JATETerm> extract(SolrCore core, JATEProperties properties) throws JATEException { SolrIndexSearcher searcher = core.getSearcher().get(); try { this.freqFeatureBuilder = new FrequencyTermBasedFBMaster(searcher, properties, 0); this.freqFeature = (FrequencyTermBased) freqFeatureBuilder.build(); Set<String> uniqueCandidateTerms = freqFeature.getMapTerm2TTF().keySet(); TermComponentIndexFBMaster termCompIndexFeatureBuilder = new TermComponentIndexFBMaster(properties, new ArrayList<>(uniqueCandidateTerms)); TermComponentIndex termComponentIndexFeature = (TermComponentIndex) termCompIndexFeatureBuilder.build(); ContainmentFBMaster cb = new ContainmentFBMaster(searcher, properties, termComponentIndexFeature, uniqueCandidateTerms); Containment cf = (Containment) cb.build(); Basic basic = new Basic(); basic.registerFeature(FrequencyTermBased.class.getName(), this.freqFeature); basic.registerFeature(Containment.class.getName(), cf); List<String> candidates = new ArrayList<>(this.freqFeature.getMapTerm2TTF().keySet()); filterByTTF(candidates); List<JATETerm> terms = basic.execute(candidates); terms = cutoff(terms); addAdditionalTermInfo(terms, searcher, properties.getSolrFieldNameJATENGramInfo(), properties.getSolrFieldNameID()); LOG.info("Complete Basic term extraction."); return terms; } finally { try { searcher.close(); } catch (IOException e) { LOG.error(e.toString()); } } }
Example 2
Source File: CompositeTermRecognitionProcessor.java From jate with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Boolean candidateExtraction(SolrCore core, String jatePropertyFile) throws IOException, JATEException { SolrIndexSearcher indexSearcher = core.getSearcher().get(); IndexWriter writerIn = null; try { writerIn = core.getSolrCoreState().getIndexWriter(core).get(); Map<String,List<CopyField>> copyFields = core.getLatestSchema().getCopyFieldsMap(); for (int i=0; i<indexSearcher.maxDoc(); i++) { Document doc = indexSearcher.doc(i); SolrUtil.copyFields(copyFields, DEFAULT_BOOST_VALUE, doc); writerIn.updateDocument(new Term("id",doc.get("id")), doc); } writerIn.commit(); return true; } finally { indexSearcher.close(); if (writerIn != null) { writerIn.close(); } } }
Example 3
Source File: AppComboBasic.java From jate with GNU Lesser General Public License v3.0 | 4 votes |
public List<JATETerm> extract(SolrCore core, JATEProperties properties) throws JATEException { SolrIndexSearcher searcher = core.getSearcher().get(); try { this.freqFeatureBuilder = new FrequencyTermBasedFBMaster(searcher, properties, 0); this.freqFeature = (FrequencyTermBased) freqFeatureBuilder.build(); Set<String> uniqueCandidateTerms = freqFeature.getMapTerm2TTF().keySet(); TermComponentIndexFBMaster termCompIndexFeatureBuilder = new TermComponentIndexFBMaster(properties, new ArrayList<>(uniqueCandidateTerms)); TermComponentIndex termComponentIndexFeature = (TermComponentIndex) termCompIndexFeatureBuilder.build(); ContainmentFBMaster cb = new ContainmentFBMaster(searcher, properties, termComponentIndexFeature, uniqueCandidateTerms); Containment cf = (Containment) cb.build(); Containment crf = (Containment)new ContainmentReverseBuilder(searcher, properties, cf).build(); ComboBasic cbasic = new ComboBasic(); cbasic.registerFeature(FrequencyTermBased.class.getName(), this.freqFeature); cbasic.registerFeature(ComboBasic.CONTAINMENT_PARENT+Containment.class.getName(), cf); cbasic.registerFeature(ComboBasic.CONTAINMENT_CHILD+Containment.class.getName(), crf); List<String> candidates = new ArrayList<>(this.freqFeature.getMapTerm2TTF().keySet()); filterByTTF(candidates); List<JATETerm> terms = cbasic.execute(candidates); terms = cutoff(terms); addAdditionalTermInfo(terms, searcher, properties.getSolrFieldNameJATENGramInfo(), properties.getSolrFieldNameID()); LOG.info("Complete ComboBasic term extraction."); return terms; } finally { try { searcher.close(); } catch (IOException e) { LOG.error(e.toString()); } } }
Example 4
Source File: TermRecognitionRequestHandler.java From jate with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { log.info("Term recognition request handler..."); setTopInitArgsAsInvariants(req); final String jatePropertyFile = req.getParams().get(JATE_PROPERTY_FILE); final String algorithmName = req.getParams().get(TERM_RANKING_ALGORITHM); final Boolean isExtraction = req.getParams().getBool(CANDIDATE_EXTRACTION); final String outFilePath = req.getParams().get(AppParams.OUTPUT_FILE.getParamKey()); final Boolean isIndexTerms = req.getParams().getBool(INDEX_TERM); final Boolean isBoosted = req.getParams().getBool(BOOSTING); final Algorithm algorithm = getAlgorithm(algorithmName); JATEProperties properties = App.getJateProperties(jatePropertyFile); final SolrIndexSearcher searcher = req.getSearcher(); try { if (isExtraction) { log.info("start candidate extraction (i.e., re-index of whole corpus) ..."); generalTRProcessor.candidateExtraction(searcher.getCore(), jatePropertyFile); log.info("complete candidate terms indexing."); } Map<String, String> trRunTimeParams = initialiseTRRunTimeParams(req); List<JATETerm> termList = generalTRProcessor.rankingAndFiltering(searcher.getCore(), jatePropertyFile, trRunTimeParams, algorithm); log.info(String.format("complete term recognition extraction! Finalized Term size [%s]", termList.size())); if (isExport(outFilePath)) { generalTRProcessor.export(termList); } if (isIndexTerms) { log.info("start to index filtered candidate terms ..."); indexTerms(termList, properties, searcher, isBoosted, isExtraction); //trigger 'optimise' to build new index searcher.getCore().getUpdateHandler().commit(new CommitUpdateCommand(req, true)); log.info("complete the indexing of candidate terms."); } } finally { searcher.close(); } }