Package org.apache.lucene.search

Examples of org.apache.lucene.search.FilterClause


        } else {
            XBooleanFilter bool = new XBooleanFilter();
            for (String type : types) {
                DocumentMapper docMapper = documentMapper(type);
                if (docMapper == null) {
                    bool.add(new FilterClause(new TermFilter(TypeFieldMapper.TERM_FACTORY.createTerm(type)), BooleanClause.Occur.SHOULD));
                } else {
                    bool.add(new FilterClause(docMapper.typeFilter(), BooleanClause.Occur.SHOULD));
                }
            }
            return bool;
        }
    }
View Full Code Here


                if (indexAlias == null) {
                    // This shouldn't happen unless alias disappeared after filteringAliases was called.
                    throw new InvalidAliasNameException(index, aliases[0], "Unknown alias name was passed to alias Filter");
                }
                if (indexAlias.parsedFilter() != null) {
                    combined.add(new FilterClause(indexAlias.parsedFilter(), BooleanClause.Occur.SHOULD));
                } else {
                    // The filter might be null only if filter was removed after filteringAliases was called
                    return null;
                }
            }
View Full Code Here

  }
   
  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());
  }
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());
  }
View Full Code Here

    assertEquals("Shoulds are Ored together",5,bits.cardinality());
  }
  public void testShouldsAndMustNot() 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));
    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

   
  }
  public void testShouldsAndMust() 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));
    booleanFilter.add(new FilterClause(getTermsFilter("accessRights", "admin"),BooleanClause.Occur.MUST));
    BitSet bits = booleanFilter.bits(reader);
    assertEquals("Shoulds Ored but MUST",3,bits.cardinality());
  }
View Full Code Here

    assertEquals("Shoulds Ored but MUST",3,bits.cardinality());
  }
  public void testShouldsAndMusts() 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));
    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());
  }
View Full Code Here

    assertEquals("Shoulds Ored but MUSTs ANDED",1,bits.cardinality());
  }
  public void testShouldsAndMustsAndMustNot() throws Throwable
  {
    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());
  }
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());
  }
View Full Code Here

    assertEquals("MUST",3,bits.cardinality());
  }
  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());
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.FilterClause

Copyright © 2018 www.massapicom. 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.