当前位置: 首页>>代码示例>>Java>>正文


Java TermsResponse.getTerms方法代码示例

本文整理汇总了Java中org.apache.solr.client.solrj.response.TermsResponse.getTerms方法的典型用法代码示例。如果您正苦于以下问题:Java TermsResponse.getTerms方法的具体用法?Java TermsResponse.getTerms怎么用?Java TermsResponse.getTerms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.client.solrj.response.TermsResponse的用法示例。


在下文中一共展示了TermsResponse.getTerms方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInstitutions

import org.apache.solr.client.solrj.response.TermsResponse; //导入方法依赖的package包/类
@Override
public List<String> getInstitutions() {
	SolrQuery query = new SolrQuery()
			.addTermsField(INSTITUTIONS_SORT_FIELD)
			.setRequestHandler("/terms").setTerms(true);
	Set<String> institutionsSet = Sets.newTreeSet();
	try {
		QueryResponse response = solrServer.query(query);
		TermsResponse termsResponse = response.getTermsResponse();
		List<Term> termList = termsResponse
				.getTerms(INSTITUTIONS_SORT_FIELD);
		for (Term term : termList) {
			institutionsSet.add(term.getTerm());
		}

	} catch (SolrServerException e) {
		logger.error("Error getting Solr institutions list", e);
		throw new OgpSolrException("Error getting Solr institutions list",
				e);

	}
	return new ArrayList<String>(institutionsSet);
}
 
开发者ID:OpenGeoportal,项目名称:ogpHarvester,代码行数:24,代码来源:SolrJClient.java

示例2: complete

import org.apache.solr.client.solrj.response.TermsResponse; //导入方法依赖的package包/类
public List<String> complete(String query) {
        List<String> results = new ArrayList<>();

        SolrServer solrServer = new HttpSolrServer("http://" + systemConfig.getSolrHostColonPort() + "/solr");
        SolrQuery solrQuery = new SolrQuery();
        solrQuery.setParam("qt", "/terms");
        solrQuery.setTermsLower(query);
        solrQuery.setTermsPrefix(query);
        // dataverses and files use SearchFields.NAME
//        solrQuery.addTermsField(SearchFields.NAME);
        solrQuery.addTermsField("text");
//        long datasetFieldDescription = 33L;
//        String solrFieldDatasetFieldDescription = datasetFieldService.find(datasetFieldDescription).getSolrField();
//        solrQuery.addTermsField(solrFieldDatasetFieldDescription);
        List<Term> items = null;

        try {
            logger.info("Solr query: " + solrQuery);
            QueryResponse qr = solrServer.query(solrQuery);
            TermsResponse resp = qr.getTermsResponse();
//            items = resp.getTerms(SearchFields.NAME);
            items = resp.getTerms("text");
//            items = resp.getTerms(solrFieldDatasetFieldDescription);
        } catch (SolrServerException e) {
            items = null;
        }

        if (items != null) {
            for (Term term : items) {
                logger.info("term: " + term.getTerm());
                results.add(term.getTerm());
            }
        } else {
            logger.info("no terms found");
        }

        return results;
    }
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:39,代码来源:AutoCompleteBean.java

示例3: addTerms

import org.apache.solr.client.solrj.response.TermsResponse; //导入方法依赖的package包/类
private void addTerms( NamedList<NamedList<Number>> terms, SynonymMap.Builder fieldBuilder, SynonymMap.Builder termBuilder, ArrayList<String> searchFields ) throws IOException {
  TermsResponse termsResponse = new TermsResponse( terms );
  for (String fieldName : searchFields ) {
    CharsRef fieldChars = new CharsRef( fieldName );
    List<TermsResponse.Term> termList = termsResponse.getTerms( fieldName );
    if (termList != null) {
      for (TermsResponse.Term tc : termList) {
        String term = tc.getTerm();
        Log.debug( "Add distributed term: " + fieldName + " = " + term );
        addTerm( fieldChars, term, fieldBuilder, termBuilder );
      }
    }
  }
}
 
开发者ID:lucidworks,项目名称:query-autofiltering-component,代码行数:15,代码来源:QueryAutoFilteringComponent.java

示例4: parse

import org.apache.solr.client.solrj.response.TermsResponse; //导入方法依赖的package包/类
public void parse(NamedList<NamedList<Number>> terms) {
  // exit if there is no terms
  if (terms == null) {
    return;
  }

  TermsResponse termsResponse = new TermsResponse(terms);
  
  // loop though each field and add each term+freq to map
  for (String key : fieldmap.keySet()) {
    HashMap<String, TermsResponse.Term> termmap = fieldmap.get(key);
    List<TermsResponse.Term> termlist = termsResponse.getTerms(key); 

    // skip this field if there are no terms
    if (termlist == null) {
      continue;
    }

    // loop though each term
    for (TermsResponse.Term tc : termlist) {
      String term = tc.getTerm();
      if (termmap.containsKey(term)) {
        TermsResponse.Term oldtc = termmap.get(term);
        oldtc.addFrequency(tc.getFrequency());
        termmap.put(term, oldtc);
      } else {
        termmap.put(term, tc);
      }
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:32,代码来源:TermsComponent.java

示例5: run

import org.apache.solr.client.solrj.response.TermsResponse; //导入方法依赖的package包/类
public void run( ) {

    try {
      SolrClient solrClient = getSolrClient( );
      if (solrClient == null) {
        LOG.error( "Cant't get SolrClient for " + solrHost );
        return;
      }
        
      if (suggestProcessor == null) {
        LOG.error( "Suggest Processor is NULL!" );
        return;
      }

      ModifiableSolrParams params = new ModifiableSolrParams( );
      
      params.set( TermsParams.TERMS_LIMIT, -1);
      params.set( TermsParams.TERMS_SORT, TermsParams.TERMS_SORT_INDEX);
      String[] fields = termFields.toArray( new String[ termFields.size( )] );
      params.set( TermsParams.TERMS_FIELD, fields );
      params.set( CommonParams.QT, termsHandler );
      params.set( TermsParams.TERMS, "true" );
      
      QueryResponse rsp = solrClient.query( collection, params );
      TermsResponse termsResponse = rsp.getTermsResponse( );
      
      for (String fieldName : termFields ) {

        List<TermsResponse.Term> termList = termsResponse.getTerms( fieldName );
        if (termList != null) {
          for (TermsResponse.Term tc : termList) {
            String term = tc.getTerm();
            HashMap<String,Object> meta = new HashMap<String,Object>( );
            meta.put( "collection", collection );
            meta.put( "collector", "TermVectorQueryCollector" );
            meta.put( "field", fieldName );
          
            QuerySuggestion qSuggestion = new QuerySuggestion( term, meta, null );
            suggestProcessor.addSuggestion( qSuggestion );
          }
        }
      }
    }
    catch ( Exception e ) {
              
    }
    finally {
      suggestProcessor.collectorDone( this );
    }
  }
 
开发者ID:detnavillus,项目名称:multifield_suggester_code,代码行数:51,代码来源:TermVectorQueryCollector.java


注:本文中的org.apache.solr.client.solrj.response.TermsResponse.getTerms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。