Java Code Examples for org.apache.solr.common.params.ModifiableSolrParams#getInt()

The following examples show how to use org.apache.solr.common.params.ModifiableSolrParams#getInt() . 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: TestRandomFaceting.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
private boolean isSortByCount(ModifiableSolrParams in) {
  boolean sortIsCount;
  String sortParam = in.get("facet.sort");
  sortIsCount = "count".equals(sortParam) || (sortParam==null && in.getInt("facet.limit",100)>0);
  return sortIsCount;
}
 
Example 2
Source File: DistributedFacetExistsSmallTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
private void checkRandomParams() throws Exception {
  final ModifiableSolrParams params = buildParams();
  Random rand = random();

  if (rand.nextBoolean()) {
    int from;
    params.set("q", "["+(from = rand.nextInt(maxId/2))+
                " TO "+((from-1)+(rand.nextInt(maxId)))+"]");
  }
  
  int offset = 0;
  int indexSize = 6;
  if (rand .nextInt(100) < 20) {
    if (rand.nextBoolean()) {
      offset = rand.nextInt(100) < 10 ? rand.nextInt(indexSize *2) : rand.nextInt(indexSize/3+1);
    }
    params.add("facet.offset", Integer.toString(offset));
  }

  int limit = 100;
  if (rand.nextInt(100) < 20) {
    if (rand.nextBoolean()) {
      limit = rand.nextInt(100) < 10 ? rand.nextInt(indexSize/2+1) : rand.nextInt(indexSize*2);
    }
    params.add("facet.limit", Integer.toString(limit));
  }

  if (rand.nextBoolean()) {
    params.add("facet.sort", rand.nextBoolean() ? "index" : "count");
  }

  if ( rand.nextInt(100) < 20) {
    final String[] prefixes = new String[] {"A","B","C"};
    params.add("facet.prefix", prefixes[rand.nextInt(prefixes.length)]);
  }

  // don't bother trying to to test facet.missing=true + facet.limit=0
  // distrib & non-distrib are known to behave differently in this 
  if (rand.nextInt(100) < 20 && 0 < params.getInt("facet.limit", 100)) {
    params.add("facet.missing", "true");
  }
  
  if (rand.nextInt(100) < 20) { // assigning only valid vals
    params.add("facet.mincount", rand.nextBoolean() ? "0": "1" );
  }
  
  query(params);
}