Package org.apache.lucene.sandbox.queries

Examples of org.apache.lucene.sandbox.queries.DuplicateFilter


public class DuplicateFilterBuilder implements FilterBuilder {

  @Override
  public Filter getFilter(Element e) throws ParserException {
    String fieldName = DOMUtils.getAttributeWithInheritanceOrFail(e, "fieldName");
    DuplicateFilter df = new DuplicateFilter(fieldName);

    String keepMode = DOMUtils.getAttribute(e, "keepMode", "first");
    if (keepMode.equalsIgnoreCase("first")) {
      df.setKeepMode(DuplicateFilter.KeepMode.KM_USE_FIRST_OCCURRENCE);
    } else if (keepMode.equalsIgnoreCase("last")) {
      df.setKeepMode(DuplicateFilter.KeepMode.KM_USE_LAST_OCCURRENCE);
    } else {
      throw new ParserException("Illegal keepMode attribute in DuplicateFilter:" + keepMode);
    }

    String processingMode = DOMUtils.getAttribute(e, "processingMode", "full");
    if (processingMode.equalsIgnoreCase("full")) {
      df.setProcessingMode(DuplicateFilter.ProcessingMode.PM_FULL_VALIDATION);
    } else if (processingMode.equalsIgnoreCase("fast")) {
      df.setProcessingMode(DuplicateFilter.ProcessingMode.PM_FAST_INVALIDATION);
    } else {
      throw new ParserException("Illegal processingMode attribute in DuplicateFilter:" + processingMode);
    }

    return df;
View Full Code Here


     *
     * @param property
     * @return
     */
    public Q distinct(Path<?> property) {
        return filter(new DuplicateFilter(serializer.toField(property)));
    }
View Full Code Here

        assertEquals(3, query.distinct(year).list().size());
    }

    @Test
    public void List_With_Filter() {
        Filter filter = new DuplicateFilter("year");
        assertEquals(4, query.list().size());
        assertEquals(3, query.filter(filter).list().size());
    }
View Full Code Here

TOP

Related Classes of org.apache.lucene.sandbox.queries.DuplicateFilter

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.