hit.fields(new HashMap<>(2));
/** * The hit field matching the given field name. */ public SearchHitField getField(String fieldName) { return fields().get(fieldName); }
if (fields == null) { fields = new HashMap<>(); hit.fields(fields);
@Override public Iterator<DcSearchHitField> iterator() { Map<String, DcSearchHitField> map = new HashMap<String, DcSearchHitField>(); for (Map.Entry<String, SearchHitField> entry : this.searchHit.fields().entrySet()) { map.put(entry.getKey(), DcSearchHitFieldImpl.getInstance(entry.getValue())); } return map.values().iterator(); } }
hit.fields(new HashMap<>(2));
@Override public Map<String, DcSearchHitField> fields() { Map<String, DcSearchHitField> map = new HashMap<String, DcSearchHitField>(); for (Map.Entry<String, SearchHitField> entry : this.searchHit.fields().entrySet()) { map.put(entry.getKey(), DcSearchHitFieldImpl.getInstance(entry.getValue())); } return map; }
private Optional<SearchHitField> retrieveMessageIdField(SearchHit hit) { if (hit.fields().keySet().contains(JsonMessageConstants.MESSAGE_ID)) { return Optional.ofNullable(hit.field(JsonMessageConstants.MESSAGE_ID)); } else { return Optional.empty(); } }
@Override public void hitExecute(SearchContext context, HitContext hitContext) { if (context.storedFieldsContext() != null && context.storedFieldsContext().fetchFields() == false) { return ; } ParentFieldMapper parentFieldMapper = context.mapperService().documentMapper(hitContext.hit().type()).parentFieldMapper(); if (parentFieldMapper.active() == false) { return; } String parentId = getParentId(parentFieldMapper, hitContext.reader(), hitContext.docId()); if (parentId == null) { // hit has no _parent field. Can happen for nested inner hits if parent hit is a p/c document. return; } Map<String, SearchHitField> fields = hitContext.hit().fieldsOrNull(); if (fields == null) { fields = new HashMap<>(); hitContext.hit().fields(fields); } fields.put(ParentFieldMapper.NAME, new SearchHitField(ParentFieldMapper.NAME, Collections.singletonList(parentId))); }
private void populateAnnotationFields(SearchHit hit, Document doc) { if (doc != null && hit.fields().size() > 0) { for (Map.Entry<String, SearchHitField> fieldEntry : hit.fields().entrySet()) { if (fieldEntry.getKey().startsWith(getAnnotationField())) { String fieldName = fieldEntry.getKey(); switch (fieldName) { case "efo_uri.label": doc.setEfoLabels(getStringValues(fieldEntry.getValue().getValues())); break; case "efo_uri.child_labels": doc.setChildLabels(getStringValues(fieldEntry.getValue().getValues())); break; case "efo_uri.parent_labels": doc.setParentLabels(getStringValues(fieldEntry.getValue().getValues())); break; default: String shortName = fieldName.substring("efo_uri.".length()); if (fieldName.endsWith("_rel_uris")) { doc.getRelatedIris().put(shortName, getStringValues(fieldEntry.getValue().getValues())); } else if (fieldName.endsWith("_rel_labels")) { List<String> labels = getStringValues(fieldEntry.getValue().getValues()); if (labels != null) { doc.getRelatedLabels().put(shortName, labels); } } } } } } }
hit.fields(new HashMap<>(2));
item.getMetadata().put("index", hit.getIndex()); item.getMetadata().put("type", hit.getType()); if ( hit.fields().containsKey("_timestamp")) { DateTime timestamp = new DateTime(((Long) hit.field("_timestamp").getValue()).longValue()); item.setTimestamp(timestamp); if ( hit.fields().containsKey("_parent")) { item.getMetadata().put("parent", hit.fields().get("_parent").value());
if (fields == null) { fields = new HashMap<>(); hit.fields(fields);
} else { out.writeVInt(fields.size()); for (SearchHitField hitField : fields().values()) { hitField.writeTo(out);
if (fields == null) { fields = new HashMap<>(); hit.fields(fields);
public static SearchHit createFromMap(Map<String, Object> values) { String id = get(Fields._ID, values, null); Text type = get(Fields._TYPE, values, null); NestedIdentity nestedIdentity = get(NestedIdentity._NESTED, values, null); Map<String, SearchHitField> fields = get(Fields.FIELDS, values, null); SearchHit searchHit = new SearchHit(-1, id, type, nestedIdentity, fields); searchHit.index = get(Fields._INDEX, values, null); searchHit.score(get(Fields._SCORE, values, DEFAULT_SCORE)); searchHit.version(get(Fields._VERSION, values, -1L)); searchHit.sortValues(get(Fields.SORT, values, SearchSortValues.EMPTY)); searchHit.highlightFields(get(Fields.HIGHLIGHT, values, null)); searchHit.sourceRef(get(SourceFieldMapper.NAME, values, null)); searchHit.explanation(get(Fields._EXPLANATION, values, null)); searchHit.setInnerHits(get(Fields.INNER_HITS, values, null)); List<String> matchedQueries = get(Fields.MATCHED_QUERIES, values, null); if (matchedQueries != null) { searchHit.matchedQueries(matchedQueries.toArray(new String[matchedQueries.size()])); } ShardId shardId = get(Fields._SHARD, values, null); String nodeId = get(Fields._NODE, values, null); if (shardId != null && nodeId != null) { searchHit.shard(new SearchShardTarget(nodeId, shardId, null, OriginalIndices.NONE)); } searchHit.fields(fields); return searchHit; }
if (fields == null) { fields = new HashMap<>(); hit.fields(fields);
if (fields == null) { fields = new HashMap<>(); hit.fields(fields);