Package org.apache.lucene.document

Examples of org.apache.lucene.document.Field.binaryValue()


    Field f = new StoredField("binary", b, 10, 17);
    byte[] bx = f.binaryValue().bytes;
    assertTrue(bx != null);
    assertEquals(50, bx.length);
    assertEquals(10, f.binaryValue().offset);
    assertEquals(17, f.binaryValue().length);
    doc.add(f);
    w.addDocument(doc);
    w.close();

    IndexReader ir = DirectoryReader.open(dir);
View Full Code Here


                if (field.isCompressed()) {
                  // compression is enabled for the current field
                  byte[] data = null;
                  // check if it is a binary field
                  if (field.isBinary()) {
                    data = compress(field.binaryValue());
                  }
                  else {
                    data = compress(field.stringValue().getBytes("UTF-8"));
                  }
                  final int len = data.length;
View Full Code Here

                  fieldsStream.writeBytes(data, len);
                }
                else {
                  // compression is disabled for the current field
                  if (field.isBinary()) {
                    byte[] data = field.binaryValue();
                    final int len = data.length;
                    fieldsStream.writeVInt(len);
                    fieldsStream.writeBytes(data, len);
                  }
                  else {
View Full Code Here

        final String expectedValue = "my value";
        fullInstance.setValue(expectedValue);
        final Field field = fullInstance.getLuceneField();
        assertNotNull(field);
        assertFalse(expectedValue.equals(field.stringValue()));
        assertArrayEquals(CompressionTools.compress(expectedValue.getBytes()), field.binaryValue().bytes);
    }

    @Test
    public final void testBinaryGetField() throws Exception {
        final String expectedValue = "my value";
View Full Code Here

    @Test
    public final void testBinaryGetField() throws Exception {
        final String expectedValue = "my value";
        final Field field = fullInstance.getLuceneField(expectedValue.getBytes());
        assertNotNull(field);
        assertArrayEquals(CompressionTools.compress(expectedValue.getBytes()), field.binaryValue().bytes);
    }

}
View Full Code Here

    for(int i=0;i<50;i++)
      b[i] = (byte) (i+77);

    Document doc = new Document();
    Field f = new StoredField("binary", b, 10, 17);
    byte[] bx = f.binaryValue().bytes;
    assertTrue(bx != null);
    assertEquals(50, bx.length);
    assertEquals(10, f.binaryValue().offset);
    assertEquals(17, f.binaryValue().length);
    doc.add(f);
View Full Code Here

    Document doc = new Document();
    Field f = new StoredField("binary", b, 10, 17);
    byte[] bx = f.binaryValue().bytes;
    assertTrue(bx != null);
    assertEquals(50, bx.length);
    assertEquals(10, f.binaryValue().offset);
    assertEquals(17, f.binaryValue().length);
    doc.add(f);
    w.addDocument(doc);
    w.close();
View Full Code Here

    Field f = new StoredField("binary", b, 10, 17);
    byte[] bx = f.binaryValue().bytes;
    assertTrue(bx != null);
    assertEquals(50, bx.length);
    assertEquals(10, f.binaryValue().offset);
    assertEquals(17, f.binaryValue().length);
    doc.add(f);
    w.addDocument(doc);
    w.close();

    IndexReader ir = DirectoryReader.open(dir);
View Full Code Here

      }
      else if (fieldable instanceof Field) {
        Field safeField = (Field) fieldable;
        //FIXME it seems like in new Field implementation it's possible to have multiple data types at the same time. Investigate?
        //The following sequence of else/ifs would not be appropriate.
        if ( safeField.binaryValue() != null ) {
          serializer.addFieldWithBinaryData( new LuceneFieldContext( safeField ) );
        }
        else if ( safeField.stringValue() != null ) {
          serializer.addFieldWithStringData( new LuceneFieldContext( safeField ) );
        }
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.