Package org.apache.lucene.document

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


        //String --> anything
          Class fieldType = getNestedPropertyType(result, field.name());
          //System.out.println(field.name()+", class = " + fieldType.getName());
          Object fieldValue = null;
          if(fieldType.equals(Date.class))
            fieldValue = new Date(Long.parseLong(field.stringValue()));
          else
            fieldValue = ConvertUtils.convert(field.stringValue(), fieldType);
          //System.out.println(fieldValue+", class = " + fieldValue.getClass().getName());
          setNestedProperty(result, field.name(), fieldValue);
      }
View Full Code Here


          //System.out.println(field.name()+", class = " + fieldType.getName());
          Object fieldValue = null;
          if(fieldType.equals(Date.class))
            fieldValue = new Date(Long.parseLong(field.stringValue()));
          else
            fieldValue = ConvertUtils.convert(field.stringValue(), fieldType);
          //System.out.println(fieldValue+", class = " + fieldValue.getClass().getName());
          setNestedProperty(result, field.name(), fieldValue);
      }
      results.add(result);
    }
View Full Code Here

        String fieldName = order.substring(0, order.lastIndexOf("_"));
        //System.out.println("none standard order. fieldname: " + fieldName);
        Field field = hit.getField(fieldName);
        String fieldContent = null;
        if (field != null) {
          fieldContent = field.stringValue();
        }
        if (fieldContent == null) {
          fieldContent = "not set";
        }
        request.setContextAttribute(ATTR_CURRENT_HIT_SORT_CONTENT,
View Full Code Here

  private MemoryIndex createMemoryIndex(Document doc) {
    MemoryIndex index = new MemoryIndex();
    Enumeration iter = doc.fields();
    while (iter.hasMoreElements()) {
      Field field = (Field) iter.nextElement();
      index.addField(field.name(), field.stringValue(), analyzer);
    }
    return index;
  }
 
  private RAMDirectory createRAMIndex(Document doc) {
View Full Code Here

  @Override
  public int doLogic() throws Exception {
    Document doc = docSize > 0 ? docMaker.makeDocument(docSize) : docMaker.makeDocument();

    Field f = doc.getField(DocMaker.BODY_FIELD);
    String body = f != null ? NORMALIZER.reset(f.stringValue()).replaceAll(" ") : "";
   
    f = doc.getField(DocMaker.TITLE_FIELD);
    String title = f != null ? NORMALIZER.reset(f.stringValue()).replaceAll(" ") : "";
   
    if (body.length() > 0 || title.length() > 0) {
View Full Code Here

    Field f = doc.getField(DocMaker.BODY_FIELD);
    String body = f != null ? NORMALIZER.reset(f.stringValue()).replaceAll(" ") : "";
   
    f = doc.getField(DocMaker.TITLE_FIELD);
    String title = f != null ? NORMALIZER.reset(f.stringValue()).replaceAll(" ") : "";
   
    if (body.length() > 0 || title.length() > 0) {
     
      f = doc.getField(DocMaker.DATE_FIELD);
      String date = f != null ? NORMALIZER.reset(f.stringValue()).replaceAll(" ") : "";
View Full Code Here

    String title = f != null ? NORMALIZER.reset(f.stringValue()).replaceAll(" ") : "";
   
    if (body.length() > 0 || title.length() > 0) {
     
      f = doc.getField(DocMaker.DATE_FIELD);
      String date = f != null ? NORMALIZER.reset(f.stringValue()).replaceAll(" ") : "";
     
      lineFileOut.write(title, 0, title.length());
      lineFileOut.write(SEP);
      lineFileOut.write(date, 0, date.length());
      lineFileOut.write(SEP);
View Full Code Here

          it2 = fields2.iterator();
          while (it1.hasNext()) {
            Field curField1 = (Field) it1.next();
            Field curField2 = (Field) it2.next();
            assertEquals("Different fields names for doc " + i + ".", curField1.name(), curField2.name());
            assertEquals("Different field values for doc " + i + ".", curField1.stringValue(), curField2.stringValue());
          }         
        }
      }
     
      // check dictionary and posting lists
View Full Code Here

    doc = r.document(0);
    Iterator it = doc.getFields().iterator();
    assertTrue(it.hasNext());
    Field f = (Field) it.next();
    assertEquals(f.name(), "zzz");
    assertEquals(f.stringValue(), "a b c");

    assertTrue(it.hasNext());
    f = (Field) it.next();
    assertEquals(f.name(), "aaa");
    assertEquals(f.stringValue(), "a b c");
View Full Code Here

    assertEquals(f.stringValue(), "a b c");

    assertTrue(it.hasNext());
    f = (Field) it.next();
    assertEquals(f.name(), "aaa");
    assertEquals(f.stringValue(), "a b c");

    assertTrue(it.hasNext());
    f = (Field) it.next();
    assertEquals(f.name(), "zzz");
    assertEquals(f.stringValue(), "1 2 3");
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.