Package org.apache.lucene.facet.enhancements.association

Examples of org.apache.lucene.facet.enhancements.association.AssociationIntProperty


/** Test {@link AssociationProperty}-ies. */
public class AssociationPropertyTest extends LuceneTestCase {

  @Test
  public void testAssociationCountProperty() throws FacetException {
    AssociationProperty aa1 = new AssociationIntProperty(5);
    AssociationProperty aa2 = new AssociationIntProperty(3);
    assertEquals("Wrong association for property", 5, aa1.getAssociation());
    assertEquals("Wrong association for property", 3, aa2.getAssociation());
    aa1.merge(aa2);
    assertEquals("Wrong association for property", 8, aa1.getAssociation());
  }
View Full Code Here


    assertEquals("Wrong association for property", 8.0, aa1.getFloatAssociation(), 0.00001);
  }

  @Test
  public void testEquals() {
    AssociationProperty aa1 = new AssociationIntProperty(5);
    AssociationProperty aa2 = new AssociationIntProperty(5);
    AssociationProperty aa3 = new AssociationFloatProperty(5);
    AssociationProperty aa4 = new AssociationFloatProperty(5);

    assertTrue("Should be equal", aa1.equals(aa1));
    assertTrue("Should be equal", aa1.equals(aa2));
View Full Code Here

    assertEquals("Wrong number of tokens with properties", 1, nProperties);
  }

  @Test
  public void testMultipleCategoriesWithProperties() throws FacetException {
    AssociationProperty associationProperty = new AssociationIntProperty(
        49);
    categoryContainer.addCategory(new CategoryPath("five", "six"),
        new DummyProperty(), associationProperty);
    categoryContainer.addCategory(new CategoryPath("seven", "eight"),
        new DummyProperty());
    associationProperty = new AssociationIntProperty(123);
    categoryContainer.addCategory(new CategoryPath("nine"),
        associationProperty, new DummyProperty());
    Iterator<CategoryAttribute> iterator = categoryContainer.iterator();

    // count the number of tokens, and check there is one DummyAttribute
View Full Code Here

   * @throws FacetException
   */
  @Test
  public void testCategoryAttributeMerge() throws FacetException {
    categoryContainer.addCategory(initialCatgeories[0],
        new AssociationIntProperty(2));
    categoryContainer.addCategory(initialCatgeories[0],
        new AssociationIntProperty(15));

    Iterator<CategoryAttribute> iterator = categoryContainer.iterator();

    int nCategories;
    int nAssociations = 0;
View Full Code Here

        nAssociations);
  }
 
  @Test
  public void testSerialization() throws Exception {
    AssociationProperty associationProperty = new AssociationIntProperty(
        49);
    categoryContainer.addCategory(new CategoryPath("five", "six"),
        new DummyProperty(), associationProperty);
    categoryContainer.addCategory(new CategoryPath("seven", "eight"),
        new DummyProperty());
    associationProperty = new AssociationIntProperty(123);
    categoryContainer.addCategory(new CategoryPath("nine"),
        associationProperty, new DummyProperty());
   
    ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
    ObjectOutputStream out = new ObjectOutputStream(baos);
View Full Code Here

   
    // index documents, 50% have only 'b' and all have 'a'
    for (int i = 0; i < 100; i++) {
      Document doc = new Document();
      CategoryContainer container = new CategoryContainer();
      container.addCategory(aint, new AssociationIntProperty(2));
      container.addCategory(afloat, new AssociationFloatProperty(0.5f));
      if (i % 2 == 0) { // 50
        container.addCategory(bint, new AssociationIntProperty(3));
        container.addCategory(bfloat, new AssociationFloatProperty(0.2f));
      }
      builder.setCategories(container).build(doc);
      writer.addDocument(doc);
    }
View Full Code Here

   
    // index documents, 50% have only 'b' and all have 'a'
    for (int i = 0; i < 100; i++) {
      Document doc = new Document();
      CategoryContainer container = new CategoryContainer();
      container.addCategory(aint, new AssociationIntProperty(2));
      container.addCategory(afloat, new AssociationFloatProperty(0.5f));
      if (i % 2 == 0) { // 50
        container.addCategory(bint, new AssociationIntProperty(3));
        container.addCategory(bfloat, new AssociationFloatProperty(0.2f));
      }
      builder.setCategories(container).build(doc);
      writer.addDocument(doc);
    }
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.enhancements.association.AssociationIntProperty

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.