Package com.mongodb

Examples of com.mongodb.BasicDBList


   */
  private  List<SearchSuggestPojo> reverseGeoLookup(Double latitude, Double longitude)
  {
    List<SearchSuggestPojo> locations = null;
   
    BasicDBList results = runGeoNear(latitude, longitude);
   
    if ( results != null)
    {
      locations = new ArrayList<SearchSuggestPojo>();
      if ( results.size() > 0 )
      {
        for ( int i = 0; i < 10 && i < results.size(); i++ )
        {
          BasicDBObject result = (BasicDBObject) results.get(i);
          Double distance = result.getDouble("dis");
          BasicDBObject obj = (BasicDBObject) result.get("obj");
          locations.add( buildLocation(obj, distance) );
        }
      }
View Full Code Here


    command.put("near", coordinates);
    command.put("maxDistance", MAXIMUM_DISTANCE_IN_METERS);
    CommandResult commandResult = MongoDbManager.getDB("feature").command(command);
    if ( commandResult.ok() && commandResult.containsField("results") )
    {
      BasicDBList results = (BasicDBList)commandResult.get("results");
      return results;     
    }
   
    return null;
  }
View Full Code Here

            array[0] = returnVal;
            f.addToMetadata(m.fieldName, array);
          } else { // complex object or array - in either case the engine turns these into
                // internal.NativeArray or internal.NativeObject
           
            BasicDBList outList = JavaScriptUtils.parseNativeJsObject(returnVal, engine);                       
            f.addToMetadata(m.fieldName, outList.toArray());
          }
        }
      } catch (ScriptException e) {

        _context.getHarvestStatus().logMessage(HarvestExceptionUtils.createExceptionMessage(e).toString(), true);
View Full Code Here

     
      // (or direct access as described above)
      BasicDBObject record = (BasicDBObject)value;
      String docUrl = record.getString(DocumentPojo.url_, null);
      String docTitle = record.getString(DocumentPojo.title_, null);
      BasicDBList tags = (BasicDBList) record.get(DocumentPojo.tags_);
     
      // 2] Processing and output/folding
     
      //TODO: now do whatever processing you want to and emit (as many times as you want) as follows:
      // example, count tags
View Full Code Here

            docBucket.nLuceneIndex = scoreObj.nIndex;     
          }       
        }     
        docBucket.manualWeighting = this.getManualScoreWeights(scoreParams, f);
       
        BasicDBList l = (BasicDBList)(f.get(DocumentPojo.entities_));
        if (null != l) {
   
          long nEntsInDoc = l.size();
          double dBestGeoScore = 0.0; // (for low accuracy geo only)
          for(Iterator<?> e0 = l.iterator(); e0.hasNext();){         
            BasicDBObject e = (BasicDBObject)e0.next()
            BasicDBObject tmpGeotag = null;
            if (_s3_bLowAccuracyGeo || (null != _s1_dManualGeoDecay_latLonInvdecay)) {
              // low accuracy geo, need to look for geotag
              tmpGeotag = (BasicDBObject) e.get(EntityPojo.geotag_);
View Full Code Here

        }
        if (!_s0_sortingByDate) {
          f.put(DocumentPojo.score_, qsf.totalScore);
        }
 
        BasicDBList l = (BasicDBList)(f.get(DocumentPojo.entities_));

        // Handle update ids vs normal ids:
        ObjectId updateId = (ObjectId) f.get(DocumentPojo.updateId_);
        if (null != updateId) { // swap the 2...
          f.put(DocumentPojo.updateId_, f.get(DocumentPojo._id_));
          f.put(DocumentPojo._id_, updateId);
        }
       
        // Check if entities enabled       
        if ((null != l) && (!_s0_bGeoEnts && !_s0_bNonGeoEnts)) {
          f.removeField(DocumentPojo.entities_);
          l = null;
        }//TESTED
       
        // Check if events etc enabled
        if ((!_s0_bEvents && !_s0_bFacts && !_s0_bSummaries)) {
          f.removeField(DocumentPojo.associations_);                   
        }//TESTED       
        else if (!_s0_bEvents || !_s0_bFacts || !_s0_bSummaries || (null != _s0_assocVerbFilter)) {         
         
          // Keep only specified event_types
          BasicDBList lev = (BasicDBList)(f.get(DocumentPojo.associations_));
          if (null != lev) {
            for(Iterator<?> e0 = lev.iterator(); e0.hasNext();){
              BasicDBObject e = (BasicDBObject)e0.next();
             
              // Type filter
              boolean bNeedToFilterAndAliasAssoc = true;
              String sEvType = e.getString(AssociationPojo.assoc_type_);
View Full Code Here

    }
    // Lowest prio: average of tags
    if (null != scoreParams.tagWeights) {
      double dScore = 0.0;
      int nComps = 0;
      BasicDBList tags = (BasicDBList) doc.get(DocumentPojo.tags_);
      if (null != tags) {
        for (Object tagObj: tags) {
          String tag = (String)tagObj;
          Double dWeight = scoreParams.tagWeights.get(tag);
          if (null != dWeight) {
View Full Code Here

        ObjectMapper mapper = new ObjectMapper();
        JsonNode root = mapper.readValue(response, JsonNode.class);
        Iterator<JsonNode> iter = root.getElements();
        Iterator<String> iterNames = root.getFieldNames();
        List<JsonNode> eventNodes = new ArrayList<JsonNode>();
        BasicDBList rawEventObjects = null;
        while ( iter.hasNext() )
        {
          String currNodeName = iterNames.next();
          JsonNode currNode = iter.next();
          if (!currNodeName.equals("doc")) //we can assume these are the entities/topics
          {
            String typeGroup = currNode.get("_typeGroup").getTextValue();
            //check typegroup to see if it is an entity
            if ( typeGroup.equals("entities") )
            {
              try
              {
                EntityPojo ep = new EntityPojo();
                //get what fields we can         
                ep.setType(currNode.get("_type").getTextValue());
                try {
                  ep.setDimension(DimensionUtility.getDimensionByType(ep.getType()));
                }
                catch (java.lang.IllegalArgumentException e) {
                  ep.setDimension(EntityPojo.Dimension.What);                 
                }
                String name = "";
                JsonNode nameNode = null;
                try
                {
                  nameNode = currNode.get("name");
                  name = nameNode.getTextValue();
                }
                catch (Exception ex )
                {                 
                  logger.debug("Error parsing name node: " + currNode.toString());
                  continue;
                }
                ep.setActual_name(name);
                ep.setRelevance(Double.parseDouble(currNode.get("relevance").getValueAsText()));
                ep.setFrequency((long)currNode.get("instances").size());
                //attempt to get resolutions if they exist
                JsonNode resolutionNode = currNode.get("resolutions");
                if ( null != resolutionNode )
                {
                  //resolution nodes are arrays
                  JsonNode resolutionFirst = resolutionNode.get(0);
                  ep.setSemanticLinks(new ArrayList<String>());
                  ep.getSemanticLinks().add(resolutionFirst.get("id").getTextValue()); //this is a link to an alchemy page
                  ep.setDisambiguatedName(resolutionFirst.get("name").getTextValue());
                  //check if we need to create a geo object
                  if ( null != resolutionFirst.get("latitude") )
                  {
                    GeoPojo gp = new GeoPojo();
                    String lat = resolutionFirst.get("latitude").getValueAsText();
                    String lon = resolutionFirst.get("longitude").getValueAsText();
                    gp.lat = Double.parseDouble(lat);
                    gp.lon = Double.parseDouble(lon);
                    ep.setGeotag(gp);
                 
                }
                else {
                  ep.setDisambiguatedName(name); // use actual name)                 
                }
                entityNameMap.put(currNodeName.toLowerCase(), ep);
                entities.add(ep);
              }
              catch (Exception ex)
              {
                logger.error("Error creating event pojo from OpenCalaisNode: " + ex.getMessage(), ex);
              }
            }
            else if ( typeGroup.equals("relations") )
            {             
              eventNodes.add(currNode);           
            }
          }         
        }
        //handle events
        if (bAddRawEventsToMetadata) {
          // For now just re-process these into DB objects since we know that works...
          rawEventObjects = new BasicDBList();
        }
        for ( JsonNode eventNode : eventNodes )
        {         
          AssociationPojo event = parseEvent(eventNode);
          //remove useless events (an event is useless if it only has a verb (guessing currently)
          if ( null != event )
          {
            event = removeUselessEvents(event);
            if ( null != event )
            {
              events.add(event);
            }
          }
          if (bAddRawEventsToMetadata) {
            BasicDBObject eventDbo = (BasicDBObject) com.mongodb.util.JSON.parse(eventNode.toString());
            if (null != eventDbo) {
              BasicDBObject transformObj = new BasicDBObject();
              for (Map.Entry<String, Object> entries: eventDbo.entrySet()) {
                if (entries.getValue() instanceof String) {
                  String val = (String) entries.getValue();
                  EntityPojo transformVal = findMappedEntityName(val);
                  if (null != transformVal) {
                    transformObj.put(entries.getKey(), transformVal.getIndex());                   
                    transformObj.put(entries.getKey() + "__hash", val);                   
                  }
                  else {
                    transformObj.put(entries.getKey(), val);                   
                  }
                }
                else {
                  transformObj.put(entries.getKey(), entries.getValue());
                }
              }
             
              // (add to another list, which will get written to metadata)
              rawEventObjects.add(transformObj);
            }
          }
        }
        if (bAddRawEventsToMetadata) {
          partialDoc.addToMetadata("OpenCalaisEvents", rawEventObjects.toArray());
        }
        if (null != partialDoc.getEntities()) {
          partialDoc.getEntities().addAll(entities);
          partialDoc.setEntities(partialDoc.getEntities());
        }
View Full Code Here

              BasicDBObject dbo = (BasicDBObject) com.mongodb.util.JSON.parse(share.getShare());
              rp.setData(dbo, null);
            }
            catch (Exception e)
            { // Try a list instead           
              BasicDBList dbo = (BasicDBList) com.mongodb.util.JSON.parse(share.getShare());
              rp.setData(dbo, (BasePojoApiMap<BasicDBList>)null);                
            }
          }
        }
      }
View Full Code Here

               try {
                 BasicDBObject dbo = (BasicDBObject) com.mongodb.util.JSON.parse(share.getShare());
                 rp.setData(dbo, null);
               }
               catch (Exception e) { // Try a list instead
                 BasicDBList dbo = (BasicDBList) com.mongodb.util.JSON.parse(share.getShare());
                 rp.setData(dbo, (BasePojoApiMap<BasicDBList>)null);                
               }
             }
           }
           //(else error)
View Full Code Here

TOP

Related Classes of com.mongodb.BasicDBList

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.