Package org.apache.lucene.document

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


                        }
                        if (value == null) {
                            if (field.isBinary()) {
                                value = field.getBinaryValue();
                            } else {
                                value = field.stringValue();
                            }
                        }

                        if (fields == null) {
                            fields = newHashMapWithExpectedSize(2);
View Full Code Here


        byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/genericstore/test-data.json");
        Document doc = docMapper.parse(json).rootDoc();

        Fieldable f = doc.getFieldable("name");
        assertThat(f.name(), equalTo("name"));
        assertThat(f.stringValue(), equalTo("some name"));
        assertThat(f.isStored(), equalTo(true));

        FieldMappers fieldMappers = docMapper.mappers().fullName("name");
        assertThat(fieldMappers.mappers().size(), equalTo(1));
        assertThat(fieldMappers.mapper().stored(), equalTo(true));
View Full Code Here

            Document newDoc = new Document();

            for (Object obj : fieldList) {
                Fieldable field = (Fieldable) obj;

                if (!field.name().equals(TAG_FIELD) || !field.stringValue().equals(tag)) {
                    newDoc.add(field);
                }

            }
View Full Code Here

 
  public static void printDocument(Document doc){
    List<Fieldable> fields = doc.getFields();
    for(int i=0;i<fields.size();i++){
      Fieldable field = fields.get(i);
      System.out.println(field.name()+":"+field.stringValue());
    }
  }
 

  public static void convertDocument2Bean(LazyDynaBean bean,Document doc,boolean noLevel){
View Full Code Here

      List<Fieldable> fields = doc.getFields();
      if(noLevel){
        for(int i=0;i<fields.size();i++){
          Fieldable field = fields.get(i);
          if(!field.name().startsWith(LEVEL)){
            bean.set(field.name(),field.stringValue());
          }
        }
      }else{
        for(int i=0;i<fields.size();i++){
          Fieldable field = fields.get(i);
View Full Code Here

          }
        }
      }else{
        for(int i=0;i<fields.size();i++){
          Fieldable field = fields.get(i);
          bean.set(field.name(),field.stringValue());
        }
      }
    }
  }
View Full Code Here

      f.add( "type", (ftype==null)?null:ftype.getTypeName() );
      f.add( "schema", getFieldFlags( sfield ) );
      f.add( "flags", getFieldFlags( fieldable ) );
     
      Term t = new Term( fieldable.name(), fieldable.stringValue() );
      f.add( "value", (ftype==null)?null:ftype.toExternal( fieldable ) );
      f.add( "internal", fieldable.stringValue() )// may be a binary number
      f.add( "boost", fieldable.getBoost() );
      f.add( "docFreq", reader.docFreq( t ) ); // this can be 0 for non-indexed fields
           
View Full Code Here

      f.add( "schema", getFieldFlags( sfield ) );
      f.add( "flags", getFieldFlags( fieldable ) );
     
      Term t = new Term( fieldable.name(), fieldable.stringValue() );
      f.add( "value", (ftype==null)?null:ftype.toExternal( fieldable ) );
      f.add( "internal", fieldable.stringValue() )// may be a binary number
      f.add( "boost", fieldable.getBoost() );
      f.add( "docFreq", reader.docFreq( t ) ); // this can be 0 for non-indexed fields
           
      // If we have a term vector, return that
      if( fieldable.isTermVectorStored() ) {
View Full Code Here

       
        if (i > 0)
          fieldState.position += docState.analyzer == null ? 0 : docState.analyzer.getPositionIncrementGap(fieldInfo.name);

        if (!field.isTokenized()) {      // un-tokenized field
          String stringValue = field.stringValue();
          final int valueLength = stringValue.length();
          perThread.singleToken.reinit(stringValue, 0, valueLength);
          fieldState.attributeSource = perThread.singleToken;
          consumer.start(field);
View Full Code Here

            final Reader readerValue = field.readerValue();

            if (readerValue != null)
              reader = readerValue;
            else {
              String stringValue = field.stringValue();
              if (stringValue == null)
                throw new IllegalArgumentException("field must have either TokenStream, String or Reader value");
              perThread.stringReader.init(stringValue);
              reader = perThread.stringReader;
            }
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.