Package org.apache.lucene.search

Examples of org.apache.lucene.search.BooleanFilter.bits()


   
  public void testShould() throws Throwable
  {
    BooleanFilter booleanFilter = new BooleanFilter();
    booleanFilter.add(new FilterClause(getTermsFilter("price","030"),BooleanClause.Occur.SHOULD));
    BitSet bits = booleanFilter.bits(reader);
    assertEquals("Should retrieves only 1 doc",1,bits.cardinality());
  }
 
  public void testShoulds() throws Throwable
  {
View Full Code Here


  public void testShoulds() throws Throwable
  {
    BooleanFilter booleanFilter = new BooleanFilter();
    booleanFilter.add(new FilterClause(getRangeFilter("price","010", "020"),BooleanClause.Occur.SHOULD));
    booleanFilter.add(new FilterClause(getRangeFilter("price","020", "030"),BooleanClause.Occur.SHOULD));
    BitSet bits = booleanFilter.bits(reader);
    assertEquals("Shoulds are Ored together",5,bits.cardinality());
  }
  public void testShouldsAndMustNot() throws Throwable
  {
    BooleanFilter booleanFilter = new BooleanFilter();
View Full Code Here

  {
    BooleanFilter booleanFilter = new BooleanFilter();
    booleanFilter.add(new FilterClause(getRangeFilter("price","010", "020"),BooleanClause.Occur.SHOULD));
    booleanFilter.add(new FilterClause(getRangeFilter("price","020", "030"),BooleanClause.Occur.SHOULD));
    booleanFilter.add(new FilterClause(getTermsFilter("inStock", "N"),BooleanClause.Occur.MUST_NOT));
    BitSet bits = booleanFilter.bits(reader);
    assertEquals("Shoulds Ored but AndNot",4,bits.cardinality());

    booleanFilter.add(new FilterClause(getTermsFilter("inStock", "Maybe"),BooleanClause.Occur.MUST_NOT));
    bits = booleanFilter.bits(reader);
    assertEquals("Shoulds Ored but AndNots",3,bits.cardinality());
View Full Code Here

    booleanFilter.add(new FilterClause(getTermsFilter("inStock", "N"),BooleanClause.Occur.MUST_NOT));
    BitSet bits = booleanFilter.bits(reader);
    assertEquals("Shoulds Ored but AndNot",4,bits.cardinality());

    booleanFilter.add(new FilterClause(getTermsFilter("inStock", "Maybe"),BooleanClause.Occur.MUST_NOT));
    bits = booleanFilter.bits(reader);
    assertEquals("Shoulds Ored but AndNots",3,bits.cardinality());
   
  }
  public void testShouldsAndMust() throws Throwable
  {
View Full Code Here

  {
    BooleanFilter booleanFilter = new BooleanFilter();
    booleanFilter.add(new FilterClause(getRangeFilter("price","010", "020"),BooleanClause.Occur.SHOULD));
    booleanFilter.add(new FilterClause(getRangeFilter("price","020", "030"),BooleanClause.Occur.SHOULD));
    booleanFilter.add(new FilterClause(getTermsFilter("accessRights", "admin"),BooleanClause.Occur.MUST));
    BitSet bits = booleanFilter.bits(reader);
    assertEquals("Shoulds Ored but MUST",3,bits.cardinality());
  }
  public void testShouldsAndMusts() throws Throwable
  {
    BooleanFilter booleanFilter = new BooleanFilter();
View Full Code Here

    BooleanFilter booleanFilter = new BooleanFilter();
    booleanFilter.add(new FilterClause(getRangeFilter("price","010", "020"),BooleanClause.Occur.SHOULD));
    booleanFilter.add(new FilterClause(getRangeFilter("price","020", "030"),BooleanClause.Occur.SHOULD));
    booleanFilter.add(new FilterClause(getTermsFilter("accessRights", "admin"),BooleanClause.Occur.MUST));
    booleanFilter.add(new FilterClause(getRangeFilter("date","20040101", "20041231"),BooleanClause.Occur.MUST));
    BitSet bits = booleanFilter.bits(reader);
    assertEquals("Shoulds Ored but MUSTs ANDED",1,bits.cardinality());
  }
  public void testShouldsAndMustsAndMustNot() throws Throwable
  {
    BooleanFilter booleanFilter = new BooleanFilter();
View Full Code Here

    BooleanFilter booleanFilter = new BooleanFilter();
    booleanFilter.add(new FilterClause(getRangeFilter("price","030", "040"),BooleanClause.Occur.SHOULD));
    booleanFilter.add(new FilterClause(getTermsFilter("accessRights", "admin"),BooleanClause.Occur.MUST));
    booleanFilter.add(new FilterClause(getRangeFilter("date","20050101", "20051231"),BooleanClause.Occur.MUST));
    booleanFilter.add(new FilterClause(getTermsFilter("inStock","N"),BooleanClause.Occur.MUST_NOT));
    BitSet bits = booleanFilter.bits(reader);
    assertEquals("Shoulds Ored but MUSTs ANDED and MustNot",0,bits.cardinality());
  }
 
  public void testJustMust() throws Throwable
  {
View Full Code Here

 
  public void testJustMust() throws Throwable
  {
    BooleanFilter booleanFilter = new BooleanFilter();
    booleanFilter.add(new FilterClause(getTermsFilter("accessRights", "admin"),BooleanClause.Occur.MUST));
    BitSet bits = booleanFilter.bits(reader);
    assertEquals("MUST",3,bits.cardinality());
  }
  public void testJustMustNot() throws Throwable
  {
    BooleanFilter booleanFilter = new BooleanFilter();
View Full Code Here

  }
  public void testJustMustNot() throws Throwable
  {
    BooleanFilter booleanFilter = new BooleanFilter();
    booleanFilter.add(new FilterClause(getTermsFilter("inStock","N"),BooleanClause.Occur.MUST_NOT));
    BitSet bits = booleanFilter.bits(reader);
    assertEquals("MUST_NOT",4,bits.cardinality());
  }
  public void testMustAndMustNot() throws Throwable
  {
    BooleanFilter booleanFilter = new BooleanFilter();
View Full Code Here

  public void testMustAndMustNot() throws Throwable
  {
    BooleanFilter booleanFilter = new BooleanFilter();
    booleanFilter.add(new FilterClause(getTermsFilter("inStock","N"),BooleanClause.Occur.MUST));
    booleanFilter.add(new FilterClause(getTermsFilter("price","030"),BooleanClause.Occur.MUST_NOT));
    BitSet bits = booleanFilter.bits(reader);
    assertEquals("MUST_NOT wins over MUST for same docs",0,bits.cardinality());
  }

 
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.