Package com.ikanow.infinit.e.data_model.api.knowledge

Examples of com.ikanow.infinit.e.data_model.api.knowledge.DimensionListPojo


    SearchResponse rsp = gazIndex.doQuery(queryObj, searchOptions);

    // Format the return values

    SearchHit[] docs = rsp.getHits().getHits();     
    DimensionListPojo dimlist = new DimensionListPojo();
    int nDocsAdded = 0;
   
    if (null != extraEntries) { // Put the alias masters at the top:
      //DEBUG
      //System.out.println(Arrays.toString(extraEntries.toArray()));
      for (EntityFeaturePojo alias: extraEntries) {
        SearchSuggestPojo sp = new SearchSuggestPojo();
        if (null != alias.getDimension()) {
          sp.setDimension(alias.getDimension().toString());
        }
        else {
          sp.setDimension("What");
        }
        sp.setValue(alias.getDisambiguatedName());
        sp.setType(alias.getType());
        if (bIncludeGeo) {
          sp.setGeotag(alias.getGeotag());
        }
        sp.setOntology_type(alias.getOntology_type());
        dimlist.addSearchSuggestPojo(sp);
      }
    }//TESTED (inc geo)
   
    if (null != docs)
    {
      for (SearchHit hit: docs)
      {
        SearchHitField shf = hit.field(EntityFeaturePojo.disambiguated_name_);
        if (null == shf) { // robustness check, sometimes if the harvester goes wrong this field might be missing
          continue;
        }
        String disname = (String) shf.value();
        String type = (String) hit.field(EntityFeaturePojo.type_).value();
        String dimension = (String) hit.field(EntityFeaturePojo.dimension_).value();
        SearchSuggestPojo sp = new SearchSuggestPojo();       

        sp.setValue(disname);
        sp.setDimension(dimension);
        sp.setType(type);
        if (bIncludeGeo)
        {
          SearchHitField loc = hit.field(EntityFeaturePojo.geotag_);
          if ( loc != null )
            sp.setLocFromES((String) loc.value());
          SearchHitField ont = hit.field(EntityFeaturePojo.ontology_type_);
          if ( ont != null )
            sp.setOntology_type((String)ont.value());
        }
        if (bIncludeLinkdata) {
          SearchHitField linkdata = hit.field(EntityFeaturePojo.linkdata_);
          if ( linkdata != null )
            sp.setLinkdata(linkdata.values());
        }               

        // More alias handling
        String index = null;
        if (null != aliasTable) {
          index = (String) hit.field(EntityFeaturePojo.index_).value();
          EntityFeaturePojo alias = aliasTable.getAliasMaster(index);
          if (null != alias) { // Found!
            if (alias.getIndex().equalsIgnoreCase("discard")) { // Discard this entity
              continue;
            }
            else if ((null != alias.getDisambiguatedName()) && (null != alias.getType())) {
              // (these need to be present)

              //DEBUG (perf critical)
              //logger.debug("Alias! Replace " + index + " with " + alias.getIndex());

              index = alias.getIndex();
              disname = alias.getDisambiguatedName();
              type = alias.getType();
              if (null != alias.getDimension()) {
                dimension = alias.getDimension().toString();
              }
              else { // Guess from type
                dimension = DimensionUtility.getDimensionByType(type).toString();
              }
              // Reset values:
              sp.setValue(disname);
              sp.setDimension(dimension);
              sp.setType(type);
            }
          }
          SearchSuggestPojo existing = aliasResults.get(index);
          if (null != existing) {

            //DEBUG (perf critical)
            //logger.debug("Alias! Remove duplicate " + index);

            if ((null == existing.getGeotag()) && (null != sp.getGeotag())) {
              // (if they're both set then sigh just ignore on a first-come-first-served basis)
              existing.setGeotag(sp.getGeotag());
              existing.setOntology_type(sp.getOntology_type());
            }//TESTED
            if (null != sp.getLinkdata()) { // (here we can just combine the linkdata)
              if (null == existing.getLinkdata()) {
                existing.setLinkdata(sp.getLinkdata());
              }
              else {
                existing.getLinkdata().addAll(sp.getLinkdata());
              }
            }//TESTED
            continue; // (ie don't add this guy)
          }
          else { // add it
            aliasResults.put(index, sp);
          }
        }
        //TESTED
        // end more alias handing               

        dimlist.addSearchSuggestPojo(sp);
        // (only adds unique entries, ie handles multiple communities "ok" (only ok
        //  because it doesn't sum the doccounts across multiple communities, you'd probably
        //  want to use facets for that, but it doesn't seem worth it, especially since we're
        //  pretty short on field cache space)
View Full Code Here

TOP

Related Classes of com.ikanow.infinit.e.data_model.api.knowledge.DimensionListPojo

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.