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


Java TermsParams类代码示例

本文整理汇总了Java中org.apache.solr.common.params.TermsParams的典型用法代码示例。如果您正苦于以下问题:Java TermsParams类的具体用法?Java TermsParams怎么用?Java TermsParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TermsParams类属于org.apache.solr.common.params包,在下文中一共展示了TermsParams类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printStats

import org.apache.solr.common.params.TermsParams; //导入依赖的package包/类
/**
 * Gibt für das übergebene Indexfeld die drei Indexterme aus, die die größte Document Frequency haben.
 * Es werden hierbei aber nur Indexterme betrachtet, die mit einem Buchstaben beginnen.
 *
 * @param indexFieldName Feldname des Indexfelds
 */
private void printStats(String indexFieldName) {
    System.out.println("- - - - - Field Statistics for Index Field " + indexFieldName + " - - - - -");
    SolrQuery query = new SolrQuery();
    query.setRequestHandler("/terms");
    query.setTermsLimit(3);
    query.setTermsSortString(TermsParams.TERMS_SORT_COUNT);
    query.addTermsField(indexFieldName);
    query.setTermsRegex("^[a-zA-Z].*");

    QueryRequest request = new QueryRequest(query);
    request.setBasicAuthCredentials(Configuration.USERNAME, Configuration.PASSWORD);
    try {
        List<TermsResponse.Term> terms = request.process(solrClient).getTermsResponse().getTerms(indexFieldName);
        if (terms != null) {
            for (TermsResponse.Term term : terms) {
                System.out.println(term.getTerm() + " (df = " + term.getFrequency() + ")");
            }
        }
    } catch (SolrServerException|IOException e) {
        System.err.println("Fehler bei der Term-Lookup im Dictionary");
    }
}
 
开发者ID:saschaszott,项目名称:suma-tech,代码行数:29,代码来源:Autocompletion.java

示例2: setTerms

import org.apache.solr.common.params.TermsParams; //导入依赖的package包/类
/** enable/disable terms.  
 * 
 * @param b flag to indicate terms should be enabled. <br /> if b==false, removes all other terms parameters
 * @return Current reference (<i>this</i>)
 */
public SolrQuery setTerms(boolean b) {
  if (b) {
    this.set(TermsParams.TERMS, true);
  } else {
    this.remove(TermsParams.TERMS);
    this.remove(TermsParams.TERMS_FIELD);
    this.remove(TermsParams.TERMS_LOWER);
    this.remove(TermsParams.TERMS_UPPER);
    this.remove(TermsParams.TERMS_UPPER_INCLUSIVE);
    this.remove(TermsParams.TERMS_LOWER_INCLUSIVE);
    this.remove(TermsParams.TERMS_LIMIT);
    this.remove(TermsParams.TERMS_PREFIX_STR);
    this.remove(TermsParams.TERMS_MINCOUNT);
    this.remove(TermsParams.TERMS_MAXCOUNT);
    this.remove(TermsParams.TERMS_RAW);
    this.remove(TermsParams.TERMS_SORT);
    this.remove(TermsParams.TERMS_REGEXP_STR);
    this.remove(TermsParams.TERMS_REGEXP_FLAG);
  }
  return this;
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:SolrQuery.java

示例3: testRegexpFlagParsing

import org.apache.solr.common.params.TermsParams; //导入依赖的package包/类
@Test
public void testRegexpFlagParsing() {
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.add(TermsParams.TERMS_REGEXP_FLAG, "case_insensitive", "literal", "comments", "multiline", "unix_lines",
            "unicode_case", "dotall", "canon_eq");
    int flags = new TermsComponent().resolveRegexpFlags(params);
    int expected = Pattern.CASE_INSENSITIVE | Pattern.LITERAL | Pattern.COMMENTS | Pattern.MULTILINE | Pattern.UNIX_LINES
            | Pattern.UNICODE_CASE | Pattern.DOTALL | Pattern.CANON_EQ;
    assertEquals(expected, flags);
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:TermsComponentTest.java

示例4: getTerms

import org.apache.solr.common.params.TermsParams; //导入依赖的package包/类
private List<TermsResponse.Term> getTerms (String field) throws SolrServerException {
    SolrQuery solrQuery = new SolrQuery();
    solrQuery.setParam(CommonParams.QT, "/terms");
    solrQuery.setParam(TermsParams.TERMS, true);
    solrQuery.setParam(TermsParams.TERMS_LIMIT, "100");
    solrQuery.setParam(TermsParams.TERMS_FIELD, field);
    QueryResponse resp = solr.query(solrQuery);
    return resp.getTermsResponse().getTermMap().get(field);
}
 
开发者ID:safarijv,项目名称:ifpress-solr-plugin,代码行数:10,代码来源:FieldMergingProcessorTest.java

示例5: buildTermQuery

import org.apache.solr.common.params.TermsParams; //导入依赖的package包/类
/**
 * Builds SolrQuery suitable to the TermsComponent.
 *
 * @param fieldName solr field to be searched
 * @param limit maximum number of results
 * @return a {@link SolrQuery}
 */
public static SolrQuery buildTermQuery(String fieldName, Integer limit) {
  SolrQuery solrQuery = new SolrQuery();
  solrQuery.setParam(CommonParams.QT, TERMS_COMP_PATH);
  solrQuery.setParam(TermsParams.TERMS, true);
  solrQuery.setParam(TermsParams.TERMS_LIMIT, limit.toString());
  solrQuery.setParam(TermsParams.TERMS_FIELD, fieldName);
  solrQuery.setParam(TermsParams.TERMS_SORT, TermsParams.TERMS_SORT_INDEX);
  return solrQuery;
}
 
开发者ID:gbif,项目名称:common-search,代码行数:17,代码来源:QueryUtils.java

示例6: run

import org.apache.solr.common.params.TermsParams; //导入依赖的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

示例7: addDistributedTerms

import org.apache.solr.common.params.TermsParams; //导入依赖的package包/类
private void addDistributedTerms( ResponseBuilder rb, SynonymMap.Builder fieldBuilder, SynonymMap.Builder termBuilder, ArrayList<String> searchFields ) throws IOException {
  SolrIndexSearcher searcher = rb.req.getSearcher();
  CoreContainer container = searcher.getCore().getCoreDescriptor().getCoreContainer();
    
  ShardHandlerFactory shardHandlerFactory = container.getShardHandlerFactory( );
  ShardHandler shardHandler = shardHandlerFactory.getShardHandler();
  shardHandler.checkDistributed( rb );
    
  Log.debug( "Is Distributed = " + rb.isDistrib );
    
  if( rb.isDistrib ) {
    // create a ShardRequest that contains a Terms Request.
    // don't send to this shard???
    ShardRequest sreq = new ShardRequest();
    sreq.purpose = ShardRequest.PURPOSE_GET_TERMS;
    sreq.actualShards = rb.shards;
    ModifiableSolrParams params = new ModifiableSolrParams( );
      
    params.set( TermsParams.TERMS_LIMIT, -1);
    params.set( TermsParams.TERMS_SORT, TermsParams.TERMS_SORT_INDEX);
    String[] fields = searchFields.toArray( new String[ searchFields.size( )] );
    params.set( TermsParams.TERMS_FIELD, fields );
      
    params.set( CommonParams.DISTRIB, "false" );
    params.set( ShardParams.IS_SHARD, true );
    params.set( ShardParams.SHARDS_PURPOSE, sreq.purpose );
    params.set( CommonParams.QT, termsHandler );
    params.set( TermsParams.TERMS, "true" );
      
    if (rb.requestInfo != null) {
      params.set("NOW", Long.toString(rb.requestInfo.getNOW().getTime()));
    }
    sreq.params = params;
      
    for (String shard : rb.shards ) {
      Log.debug( "sending request to shard " + shard );
      params.set(ShardParams.SHARD_URL, shard );
      shardHandler.submit( sreq, shard, params );
    }
      
    ShardResponse rsp = shardHandler.takeCompletedIncludingErrors( );
    if (rsp != null) {
      Log.debug( "got " + rsp.getShardRequest().responses.size( ) + " responses" );
      for ( ShardResponse srsp : rsp.getShardRequest().responses ) {
        Log.debug( "Got terms response from " + srsp.getShard( ));
      
        if (srsp.getException() != null) {
          Log.debug( "ShardResponse Exception!! " + srsp.getException( ) );
        }
      
        @SuppressWarnings("unchecked")
        NamedList<NamedList<Number>> terms = (NamedList<NamedList<Number>>) srsp.getSolrResponse().getResponse().get("terms");
        if (terms != null) {
          addTerms( terms, fieldBuilder, termBuilder, searchFields );
        }
        else {
          Log.warn( "terms was NULL! - make sure that /terms request handler is defined in solrconfig.xml" );
        }
      }
    }
  }
}
 
开发者ID:lucidworks,项目名称:query-autofiltering-component,代码行数:63,代码来源:QueryAutoFilteringComponent.java

示例8: addDistributedTerms

import org.apache.solr.common.params.TermsParams; //导入依赖的package包/类
private void addDistributedTerms( ResponseBuilder rb, SynonymMap.Builder fieldBuilder, SynonymMap.Builder termBuilder, ArrayList<String> searchFields ) throws IOException {
  SolrIndexSearcher searcher = rb.req.getSearcher();
  CoreContainer container = searcher.getCore().getCoreDescriptor().getCoreContainer();
    
  ShardHandlerFactory shardHandlerFactory = container.getShardHandlerFactory( );
  ShardHandler shardHandler = shardHandlerFactory.getShardHandler();
  shardHandler.checkDistributed( rb );
    
  Log.debug( "Is Distributed = " + rb.isDistrib );
    
  if( rb.isDistrib ) {
    // create a ShardRequest that contains a Terms Request.
    // don't send to this shard???
    ShardRequest sreq = new ShardRequest();
    sreq.purpose = ShardRequest.PURPOSE_GET_TERMS;
    sreq.actualShards = rb.shards;
    ModifiableSolrParams params = new ModifiableSolrParams( );
      
    params.set( TermsParams.TERMS_LIMIT, -1);
    params.set( TermsParams.TERMS_SORT, TermsParams.TERMS_SORT_INDEX);
    String[] fields = searchFields.toArray( new String[ searchFields.size( )] );
    params.set( TermsParams.TERMS_FIELD, fields );
      
    params.set( CommonParams.DISTRIB, "false" );
    params.set( ShardParams.IS_SHARD, true );
    params.set( "shards.purpose", sreq.purpose );
    params.set( CommonParams.QT, termsHandler );
    params.set( TermsParams.TERMS, "true" );
      
    if (rb.requestInfo != null) {
      params.set("NOW", Long.toString(rb.requestInfo.getNOW().getTime()));
    }
    sreq.params = params;
      
    for (String shard : rb.shards ) {
      Log.debug( "sending request to shard " + shard );
      params.set(ShardParams.SHARD_URL, shard );
      shardHandler.submit( sreq, shard, params );
    }
      
    ShardResponse rsp = shardHandler.takeCompletedIncludingErrors( );
    if (rsp != null) {
      Log.debug( "got " + rsp.getShardRequest().responses.size( ) + " responses" );
      for ( ShardResponse srsp : rsp.getShardRequest().responses ) {
        Log.debug( "Got terms response from " + srsp.getShard( ));
      
        if (srsp.getException() != null) {
          Log.warn( "ShardResponse Exception!! " + srsp.getException( ) );
        }
      
        @SuppressWarnings("unchecked")
        NamedList<NamedList<Number>> terms = (NamedList<NamedList<Number>>) srsp.getSolrResponse().getResponse().get("terms");
        if (terms != null) {
          addTerms( terms, fieldBuilder, termBuilder, searchFields );
        }
        else {
          Log.warn( "terms was NULL! - make sure that /terms request handler is defined in solrconfig.xml" );
        }
      }
    }
  }
}
 
开发者ID:lucidworks,项目名称:query-autofiltering-component,代码行数:63,代码来源:QueryAutoFilteringComponent.java

示例9: getTerms

import org.apache.solr.common.params.TermsParams; //导入依赖的package包/类
public boolean getTerms() {
  return this.getBool(TermsParams.TERMS, false);
}
 
开发者ID:europeana,项目名称:search,代码行数:4,代码来源:SolrQuery.java

示例10: addTermsField

import org.apache.solr.common.params.TermsParams; //导入依赖的package包/类
public SolrQuery addTermsField(String field) {
  this.add(TermsParams.TERMS_FIELD, field);
  return this;
}
 
开发者ID:europeana,项目名称:search,代码行数:5,代码来源:SolrQuery.java

示例11: getTermsFields

import org.apache.solr.common.params.TermsParams; //导入依赖的package包/类
public String[] getTermsFields() {
  return this.getParams(TermsParams.TERMS_FIELD);
}
 
开发者ID:europeana,项目名称:search,代码行数:4,代码来源:SolrQuery.java

示例12: setTermsLower

import org.apache.solr.common.params.TermsParams; //导入依赖的package包/类
public SolrQuery setTermsLower(String lower) {
  this.set(TermsParams.TERMS_LOWER, lower);
  return this;
}
 
开发者ID:europeana,项目名称:search,代码行数:5,代码来源:SolrQuery.java

示例13: getTermsLower

import org.apache.solr.common.params.TermsParams; //导入依赖的package包/类
public String getTermsLower() {
  return this.get(TermsParams.TERMS_LOWER, "");
}
 
开发者ID:europeana,项目名称:search,代码行数:4,代码来源:SolrQuery.java

示例14: setTermsUpper

import org.apache.solr.common.params.TermsParams; //导入依赖的package包/类
public SolrQuery setTermsUpper(String upper) {
  this.set(TermsParams.TERMS_UPPER, upper);
  return this;
}
 
开发者ID:europeana,项目名称:search,代码行数:5,代码来源:SolrQuery.java

示例15: getTermsUpper

import org.apache.solr.common.params.TermsParams; //导入依赖的package包/类
public String getTermsUpper() {
  return this.get(TermsParams.TERMS_UPPER, "");
}
 
开发者ID:europeana,项目名称:search,代码行数:4,代码来源:SolrQuery.java


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