Package org.apache.solr.common

Examples of org.apache.solr.common.SolrDocument.addField()


        if(sf != null && sf.multiValued() && !solrDoc.containsKey(fieldName)){
          ArrayList l = new ArrayList();
          l.add(val);
          solrDoc.addField(fieldName, l);
        } else {
          solrDoc.addField(fieldName, val);
        }
      }
      return solrDoc;
    }
View Full Code Here


        }
       
        // Handle multi-valued fields
        if( type == KnownType.ARR ) {
          for( Object val : readArray( parser ) ) {
            doc.addField( name, val );
          }
          depth--; // the array reading clears out the 'endElement'
        }
        else if( !type.isLeaf ) {
          throw new XMLStreamException( "must be value or array", parser.getLocation() );
View Full Code Here

        //System.out.println( "FIELD:"+type+"::"+name+"::"+builder );
        Object val = type.read( builder.toString().trim() );
        if( val == null ) {
          throw new XMLStreamException( "error reading value:"+type, parser.getLocation() );
        }
        doc.addField( name, val );
        break;

      case XMLStreamConstants.SPACE: // TODO?  should this be trimmed? make sure it only gets one/two space?
      case XMLStreamConstants.CDATA:
      case XMLStreamConstants.CHARACTERS:
View Full Code Here

    // one to a SolrDocument
    for (SearchHit hit : hits.getHits()) {
      SolrDocument doc = new SolrDocument();

      // always add score to document
      doc.addField("score", hit.score());

      // attempt to get the returned fields
      // if none returned, use the source fields
      Map<String, SearchHitField> fields = hit.getFields();
      Map<String, Object> source = hit.sourceAsMap();
View Full Code Here

              if (datePattern.matcher(fieldValue.toString()).matches()) {
                fieldValue = dateFormat.parseDateTime(fieldValue.toString()).toDate();
              }
            }

            doc.addField(sourceField, fieldValue);
          }
        }
      } else {
        for (String fieldName : fields.keySet()) {
          SearchHitField field = fields.get(fieldName);
View Full Code Here

            if (datePattern.matcher(fieldValue.toString()).matches()) {
              fieldValue = dateFormat.parseDateTime(fieldValue.toString()).toDate();
            }
          }

          doc.addField(fieldName, fieldValue);
        }
      }

      // add the SolrDocument to the SolrDocumentList
      results.add(doc);
View Full Code Here

        Document doc = searcher.doc(id, returnFields);

        SolrDocument sdoc = getDoc(doc);

        if (includeScore && ids.hasScores()) {
          sdoc.addField("score", iterator.score());
        }

        codec.writeSolrDocument(sdoc);
      }
    }
View Full Code Here

          }
        }
        if(sf != null && sf.multiValued() && !solrDoc.containsKey(fieldName)){
          ArrayList l = new ArrayList();
          l.add(val);
          solrDoc.addField(fieldName, l);
        } else {
          solrDoc.addField(fieldName, val);
        }
      }
      return solrDoc;
View Full Code Here

        if(sf != null && sf.multiValued() && !solrDoc.containsKey(fieldName)){
          ArrayList l = new ArrayList();
          l.add(val);
          solrDoc.addField(fieldName, l);
        } else {
          solrDoc.addField(fieldName, val);
        }
      }
      return solrDoc;
    }
View Full Code Here

      db.loadStoredFields(doc, luceneDoc);

      // this may be removed if XMLWriter gets patched to
      // include score from doc iterator in solrdoclist
      if (docs.hasScores()) {
        doc.addField("score", dit.score());
      } else {
        doc.addField("score", 0.0f);
      }

      list.add( doc );
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.