Package org.elasticsearch.search

Examples of org.elasticsearch.search.SearchHitField


            }
            SearchHit hit = resp.getHits().hits()[0];
            for (Map<String, String> mappingRecord : resultMapping) {
              String idx_resultField = mappingRecord.get(CFG_idx_result_field);
              Object v = null;
              SearchHitField shf = null;
              if ("_source".equals(idx_resultField)) {
                v = hit.getSource();
              } else {
                shf = hit.field(idx_resultField);
                if (shf != null) {
                  v = shf.getValue();
                }
              }
              if (shf != null || v != null) {
                if (v == null && mappingRecord.get(CFG_value_default) != null) {
                  v = ValueUtils.processStringValuePatternReplacement(mappingRecord.get(CFG_value_default), data,
View Full Code Here


            doc.addField(sourceField, fieldValue);
          }
        }
      } else {
        for (String fieldName : fields.keySet()) {
          SearchHitField field = fields.get(fieldName);
          Object fieldValue = field.getValue();

          // ES does not return date fields as Date Objects
          // detect if the string is a date, and if so
          // convert it to a Date object
          if (fieldValue.getClass() == String.class) {
View Full Code Here

        }
        size = in.readVInt();
        if (size == 0) {
            fields = ImmutableMap.of();
        } else if (size == 1) {
            SearchHitField hitField = readSearchHitField(in);
            fields = ImmutableMap.of(hitField.name(), hitField);
        } else if (size == 2) {
            SearchHitField hitField1 = readSearchHitField(in);
            SearchHitField hitField2 = readSearchHitField(in);
            fields = ImmutableMap.of(hitField1.name(), hitField1, hitField2.name(), hitField2);
        } else if (size == 3) {
            SearchHitField hitField1 = readSearchHitField(in);
            SearchHitField hitField2 = readSearchHitField(in);
            SearchHitField hitField3 = readSearchHitField(in);
            fields = ImmutableMap.of(hitField1.name(), hitField1, hitField2.name(), hitField2, hitField3.name(), hitField3);
        } else if (size == 4) {
            SearchHitField hitField1 = readSearchHitField(in);
            SearchHitField hitField2 = readSearchHitField(in);
            SearchHitField hitField3 = readSearchHitField(in);
            SearchHitField hitField4 = readSearchHitField(in);
            fields = ImmutableMap.of(hitField1.name(), hitField1, hitField2.name(), hitField2, hitField3.name(), hitField3, hitField4.name(), hitField4);
        } else if (size == 5) {
            SearchHitField hitField1 = readSearchHitField(in);
            SearchHitField hitField2 = readSearchHitField(in);
            SearchHitField hitField3 = readSearchHitField(in);
            SearchHitField hitField4 = readSearchHitField(in);
            SearchHitField hitField5 = readSearchHitField(in);
            fields = ImmutableMap.of(hitField1.name(), hitField1, hitField2.name(), hitField2, hitField3.name(), hitField3, hitField4.name(), hitField4, hitField5.name(), hitField5);
        } else {
            ImmutableMap.Builder<String, SearchHitField> builder = ImmutableMap.builder();
            for (int i = 0; i < size; i++) {
                SearchHitField hitField = readSearchHitField(in);
                builder.put(hitField.name(), hitField);
            }
            fields = builder.build();
        }

        size = in.readVInt();
View Full Code Here

            if (hitContext.hit().fieldsOrNull() == null) {
                hitContext.hit().fields(new HashMap<String, SearchHitField>(2));
            }

            SearchHitField hitField = hitContext.hit().fields().get(scriptField.name());
            if (hitField == null) {
                hitField = new InternalSearchHitField(scriptField.name(), new ArrayList<Object>(2));
                hitContext.hit().fields().put(scriptField.name(), hitField);
            }
            hitField.values().add(value);
        }
    }
View Full Code Here

                if (searchHit.fieldsOrNull() == null) {
                    searchHit.fields(new HashMap<String, SearchHitField>(2));
                }

                SearchHitField hitField = searchHit.fields().get(name);
                if (hitField == null) {
                    hitField = new InternalSearchHitField(name, new ArrayList<Object>(2));
                    searchHit.fields().put(name, hitField);
                }
                hitField.values().add(value);
            }

            int readerIndex = context.searcher().readerIndex(docId);
            IndexReader subReader = context.searcher().subReaders()[readerIndex];
            int subDoc = docId - context.searcher().docStarts()[readerIndex];
View Full Code Here

                        .execute().actionGet();
                for (SearchHit hit : searchResponse.getHits()) {
                    // for message sync - update all subscribers with the current timestamp
                    service.checkpoint(hit.getId());
                    // find node address and channel ID
                    SearchHitField channelField = hit.field("subscriber.channel");
                    Map<String, Object> channelfieldMap = channelField.getValue();
                    String nodeAddress = (String) channelfieldMap.get("localAddress");
                    Integer id = (Integer) channelfieldMap.get("id");
                    // forward to node
                    transport.forward(nodeAddress, id, messageBuilder);
                }
View Full Code Here

                searchResponse = client.prepareSearchScroll(searchResponse.getScrollId())
                        .setScroll(new TimeValue(60000))
                        .execute().actionGet();
                for (SearchHit hit : searchResponse.getHits()) {
                    service.checkpoint(hit.getId());
                    SearchHitField channelField = hit.field("subscriber.channel");
                    Map<String, Object> channelfieldMap = channelField.getValue();
                    Integer id = (Integer) channelfieldMap.get("id");
                    Channel ch = transport.channel(id);
                    if (ch != null) {
                        ch.write(new NettyInteractiveResponse("message", messageBuilder).response());
                    }
View Full Code Here

   
    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) {
View Full Code Here

      //frequency
      Set<String> suggestions = new HashSet<String>();

      for (SearchHit hit: docs)
      {
        SearchHitField retField = hit.field(returnfield); // (this can be null in theory/by mistake)
        if (null != retField) {
          String suggestion = (String) retField.value();
          if (bReturningEntities && (null != aliasTable))
          {
            // More alias handling
            EntityFeaturePojo alias = aliasTable.getAliasMaster(suggestion);
            if (null != alias) { // Found!
View Full Code Here

          if (Double.isNaN(scoreObj.score)) {
            scoreObj.score = (double) 0.0;
          }         
          avgScore += scoreObj.score;
          if (bDecay) {
            SearchHitField decay = hit.getFields().get("decay");
            if (null != decay) {
              scoreObj.decay = (Double)decay.value();
            }
          }
          ObjectId id = new ObjectId(idStr);
        scoring.put(id, scoreObj);
        ids[i++] = id;
View Full Code Here

TOP

Related Classes of org.elasticsearch.search.SearchHitField

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.