Package org.apache.solr.common

Examples of org.apache.solr.common.SolrInputField


        Signature sig = (Signature) req.getCore().getResourceLoader().newInstance(signatureClass);
        sig.init(params);

        for (String field : sigFields) {
          SolrInputField f = doc.getField(field);
          if (f != null) {
            sig.add(field);
            Object o = f.getValue();
            if (o instanceof String) {
              sig.add((String)o);
            } else if (o instanceof Collection) {
              for (Object oo : (Collection)o) {
                if (oo instanceof String) {
View Full Code Here


           schema.getUniqueKeyField();
           Fieldable storedId = doc.getFieldable(sf.getName());
           indexedId = sf.getType().storedToIndexed(storedId);
         }
         if (solrDoc != null) {
           SolrInputField field = solrDoc.getField(sf.getName());
           if (field != null) {
             indexedId = sf.getType().toInternal( field.getFirstValue().toString() );
           }
         }
       }
     }
     return indexedId;
View Full Code Here

     if (doc != null) {
       return schema.printableUniqueKey(doc);
     }

     if (solrDoc != null && sf != null) {
       SolrInputField field = solrDoc.getField(sf.getName());
       if (field != null) {
         return field.getFirstValue().toString();
       }
     }
     return "(null)";
   }
View Full Code Here

        case JSONParser.STRING:
          if( parser.wasKey() ) {
            obj = stack.peek();
            String v = parser.getString();
            if( obj instanceof SolrInputField ) {
              SolrInputField field = (SolrInputField)obj;
              if( "boost".equals( v ) ) {
                ev = parser.nextEvent();
                if( ev != JSONParser.NUMBER &&
                    ev != JSONParser.LONG && 
                    ev != JSONParser.BIGNUMBER ) {
                  throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "boost should have number! "+JSONParser.getEventString(ev) );
                }
                field.setBoost((float)parser.getDouble());
              }
              else if( "value".equals( ) ) {
                // nothing special...
                stack.push( field ); // so it can be popped
              }
              else {
                throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "invalid key: "+v + " ["+ parser.getPosition()+"]" );
              }
            }
            else if( obj instanceof SolrInputDocument ) {
              SolrInputDocument doc = (SolrInputDocument)obj;
              SolrInputField f = doc.get( v );
              if( f == null ) {
                f = new SolrInputField( v );
                doc.put( f.getName(), f );
              }
              stack.push( f );
            }
            else {
              throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "hymmm ["+ parser.getPosition()+"]" );
View Full Code Here

    Object obj = stack.peek();
    if( !(obj instanceof SolrInputField) ) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "hymmm ["+parser.getPosition()+"]" );
    }

    SolrInputField f = inArray
      ? (SolrInputField)obj
      : (SolrInputField)stack.pop();

    if (val == null) return;

    float boost = (f.getValue()==null)?f.getBoost():1.0f;
    f.addValue( val,boost );
  }
View Full Code Here

    nl.add("boost", doc.getDocumentBoost() == 1.0f ? null : doc.getDocumentBoost());
    l.add(nl);
    Iterator<SolrInputField> it = doc.iterator();
    while (it.hasNext()) {
      nl = new NamedList();
      SolrInputField field = it.next();
      nl.add("name", field.getName());
      nl.add("val", field.getValue());
      nl.add("boost", field.getBoost() == 1.0f ? null : field.getBoost());
      l.add(nl);
    }
    return l;
  }
View Full Code Here

  }

  public void classifyDocument(SolrInputDocument doc) throws IOException {
    try {
      //<start id="mahout.bayes.classify"/>
      SolrInputField field = doc.getField(inputField);
      String[] tokens = tokenizeField(inputField, field);
      ClassifierResult result = ctx.classifyDocument(tokens,
              defaultCategory);
      if (result != null && result.getLabel() != NO_LABEL) {
        doc.addField(outputField, result.getLabel());
View Full Code Here

           schema.getUniqueKeyField();
           Fieldable storedId = doc.getFieldable(sf.getName());
           indexedId = sf.getType().storedToIndexed(storedId);
         }
         if (solrDoc != null) {
           SolrInputField field = solrDoc.getField(sf.getName());
           if (field != null) {
             indexedId = sf.getType().toInternal( field.getFirstValue().toString() );
           }
         }
       }
     }
     return indexedId;
View Full Code Here

     if (doc != null) {
       return schema.printableUniqueKey(doc);
     }

     if (solrDoc != null) {
       SolrInputField field = solrDoc.getField(sf.getName());
       if (field != null) {
         return field.getFirstValue().toString();
       }
     }
     return "(null)";
   }
View Full Code Here

        case JSONParser.STRING:
          if( parser.wasKey() ) {
            obj = stack.peek();
            String v = parser.getString();
            if( obj instanceof SolrInputField ) {
              SolrInputField field = (SolrInputField)obj;
              if( "boost".equals( v ) ) {
                ev = parser.nextEvent();
                if( ev != JSONParser.NUMBER &&
                    ev != JSONParser.LONG && 
                    ev != JSONParser.BIGNUMBER ) {
                  throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "boost should have number! "+JSONParser.getEventString(ev) );
                }
                field.setBoost( Float.valueOf( parser.getNumberChars().toString() ) );
              }
              else if( "value".equals( ) ) {
                // nothing special...
                stack.push( field ); // so it can be popped
              }
              else {
                throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "invalid key: "+v + " ["+ parser.getPosition()+"]" );
              }
            }
            else if( obj instanceof SolrInputDocument ) {
              SolrInputDocument doc = (SolrInputDocument)obj;
              SolrInputField f = doc.get( v );
              if( f == null ) {
                f = new SolrInputField( v );
                doc.put( f.getName(), f );
              }
              stack.push( f );
            }
            else {
              throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "hymmm ["+ parser.getPosition()+"]" );
View Full Code Here

TOP

Related Classes of org.apache.solr.common.SolrInputField

Copyright © 2018 www.massapicom. 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.