Examples of Fieldable


Examples of org.apache.lucene.document.Fieldable

      for (int j = 0; j < fields.length; j++) {
        rtn[j]="-";
        String field=fields[j];
        if(this.isStore[j])
        {
          Fieldable fv=docfields.getFieldable(field);
          if(fv!=null)
          {
            rtn[j]=ftlist[j].toExternal(fv);
          }
        }else{
View Full Code Here

Examples of org.apache.lucene.document.Fieldable

   * The printable value of the Unique Key field for
   * the specified Document
   * @return null if this schema has no unique key field
   */
  public String printableUniqueKey(org.apache.lucene.document.Document doc) {
     Fieldable f = doc.getFieldable(uniqueKeyFieldName);
     return f==null ? null : uniqueKeyFieldType.toExternal(f);
  }
View Full Code Here

Examples of org.apache.lucene.document.Fieldable

                }else{

                  for (int j = 0; j < fields.length; j++) {
                    buff.groupbuff.append(UniqConfig.GroupJoinString());
 
                    Fieldable fv=docfields.getFieldable(fields[j]);
                   
                   
                    if(fv!=null)
                    {
                      buff.groupbuff.append(EncodeUtils.encode(ftlist[j].toExternal(fv)));
View Full Code Here

Examples of org.apache.lucene.document.Fieldable

    HashMap<String, CategoryHits> categoryHash
      = new HashMap<String, CategoryHits>();
   
    for (ScoreDoc sd: results.scoreDocs) { //<co id="mlt.collect"/>
      Document d = indexReader.document(sd.doc);
      Fieldable f = d.getFieldable(categoryFieldName);
      String cat = f.stringValue();
      CategoryHits ch = categoryHash.get(cat);
      if (ch == null) {
        ch = new CategoryHits();
        ch.setLabel(cat);
        categoryHash.put(cat, ch);
View Full Code Here

Examples of org.apache.lucene.document.Fieldable

 
  private static SimpleOrderedMap<Object> getDocumentFieldsInfo( Document doc, int docId, IndexReader reader, IndexSchema schema ) throws IOException
  {
    SimpleOrderedMap<Object> finfo = new SimpleOrderedMap<Object>();
    for( Object o : doc.getFields() ) {
      Fieldable fieldable = (Fieldable)o;
      SimpleOrderedMap<Object> f = new SimpleOrderedMap<Object>();
     
      SchemaField sfield = schema.getFieldOrNull( fieldable.name() );
      FieldType ftype = (sfield==null)?null:sfield.getType();

      f.add( "type", (ftype==null)?null:ftype.getTypeName() );
      f.add( "schema", getFieldFlags( sfield ) );
      f.add( "flags", getFieldFlags( fieldable ) );

      Term t = new Term(fieldable.name(), ftype!=null ? ftype.storedToIndexed(fieldable) : fieldable.stringValue());

      f.add( "value", (ftype==null)?null:ftype.toExternal( fieldable ) );

      // TODO: this really should be "stored"
      f.add( "internal", fieldable.stringValue() )// may be a binary number

      byte[] arr = fieldable.getBinaryValue();
      if (arr != null) {
        f.add( "binary", Base64.byteArrayToBase64(arr, 0, arr.length));
      }
      f.add( "boost", fieldable.getBoost() );
      f.add( "docFreq", t.text()==null ? 0 : reader.docFreq( t ) ); // this can be 0 for non-indexed fields
           
      // If we have a term vector, return that
      if( fieldable.isTermVectorStored() ) {
        try {
          TermFreqVector v = reader.getTermFreqVector( docId, fieldable.name() );
          if( v != null ) {
            SimpleOrderedMap<Integer> tfv = new SimpleOrderedMap<Integer>();
            for( int i=0; i<v.size(); i++ ) {
              tfv.add( v.getTerms()[i], v.getTermFrequencies()[i] );
            }
            f.add( "termVector", tfv );
          }
        }
        catch( Exception ex ) {
          log.warn( "error writing term vector", ex );
        }
      }
     
      finfo.add( fieldable.name(), f );
    }
    return finfo;
  }
View Full Code Here

Examples of org.apache.lucene.document.Fieldable

        TopDocs top = searcher.search( q, 1 );
        if( top.totalHits > 0 ) {
          // Find a document with this field
          try {
            Document doc = searcher.doc( top.scoreDocs[0].doc );
            Fieldable fld = doc.getFieldable( fieldName );
            if( fld != null ) {
              f.add( "index", getFieldFlags( fld ) );
            }
            else {
              // it is a non-stored field...
View Full Code Here

Examples of org.apache.lucene.document.Fieldable

      mapper.docNL = docNL;
      termVectors.add("doc-" + docId, docNL);

      if (keyField != null) {
        Document document = reader.document(docId, fieldSelector);
        Fieldable uniqId = document.getFieldable(uniqFieldName);
        String uniqVal = null;
        if (uniqId != null) {
          uniqVal = keyField.getType().storedToReadable(uniqId);         
        }
        if (uniqVal != null) {
View Full Code Here

Examples of org.apache.lucene.document.Fieldable

        for (Fieldable field : fields) {
          doc.add(field);
        }
      }
    } else {
      Fieldable field = sfield.createField(val, boost);
      if (field != null) {
        if (!sfield.multiValued()) {
          String oldValue = map.put(sfield.getName(), val);
          if (oldValue != null) {
            throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"ERROR: multiple values encountered for non multiValued field " + sfield.getName()
View Full Code Here

Examples of org.apache.lucene.document.Fieldable

      Fieldable[] farr = field.getType().createFields(field, val, boost);
      for (Fieldable f : farr) {
        if (f != null) doc.add(f); // null fields are not added
      }
    } else {
      Fieldable f = field.createField(val, boost);
      if (f != null) doc.add(f)// null fields are not added
    }
  }
View Full Code Here

Examples of org.apache.lucene.document.Fieldable

          hasField = true;
          boolean isBinaryField = false;
          if (sfield != null && sfield.getType() instanceof BinaryField) {
            isBinaryField = true;
            BinaryField binaryField = (BinaryField) sfield.getType();
            Fieldable f = binaryField.createField(sfield,v,boost);
            if(f != null){
              out.add(f);
            }
            used = true;
          } else {
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.