public static Mapping getMapping(String store, String key, KeyInformation.IndexRetriever information) { KeyInformation ki = information.get(store, key); Preconditions.checkArgument(ki!=null,"Could not find key information for: %s",key); return getMapping(ki); }
private static Mapping getStringMapping(KeyInformation information) { assert AttributeUtil.isString(information.getDataType()); Mapping map = Mapping.getMapping(information); if (map==Mapping.DEFAULT) map = Mapping.TEXT; return map; }
private static Mapping getStringMapping(KeyInformation information) { assert AttributeUtil.isString(information.getDataType()); Mapping map = Mapping.getMapping(information); if (map==Mapping.DEFAULT) map = Mapping.TEXT; return map; }
private String getAdditionScript(KeyInformation.IndexRetriever information, String storeName, IndexMutation mutation) throws PermanentBackendException { final StringBuilder script = new StringBuilder(); for (final IndexEntry e : mutation.getAdditions()) { final KeyInformation keyInformation = information.get(storeName).get(e.field); switch (keyInformation.getCardinality()) { case SET: case LIST: script.append("if(ctx._source[\"").append(e.field).append("\"] == null) ctx._source[\"").append(e.field).append("\"] = [];"); script.append("ctx._source[\"").append(e.field).append("\"].add(").append(convertToJsType(e.value, compat.scriptLang(), Mapping.getMapping(keyInformation))).append(");"); if (hasDualStringMapping(keyInformation)) { script.append("if(ctx._source[\"").append(getDualMappingName(e.field)).append("\"] == null) ctx._source[\"").append(getDualMappingName(e.field)).append("\"] = [];"); script.append("ctx._source[\"").append(getDualMappingName(e.field)).append("\"].add(").append(convertToJsType(e.value, compat.scriptLang(), Mapping.getMapping(keyInformation))).append(");"); } break; default: break; } } return script.toString(); }
@Override public boolean supports(KeyInformation information) { final Class<?> dataType = information.getDataType(); final Mapping mapping = Mapping.getMapping(information); if (Number.class.isAssignableFrom(dataType) || dataType == Date.class || dataType == Instant.class || dataType == Boolean.class || dataType == UUID.class) { return mapping == Mapping.DEFAULT; } else if (AttributeUtil.isString(dataType)) { return mapping == Mapping.DEFAULT || mapping == Mapping.TEXT || mapping == Mapping.STRING; } else if (AttributeUtil.isGeo(dataType)) { return mapping == Mapping.DEFAULT || mapping == Mapping.PREFIX_TREE; } return false; }
@Override public boolean supports(KeyInformation information) { final Class<?> dataType = information.getDataType(); final Mapping mapping = Mapping.getMapping(information); if (Number.class.isAssignableFrom(dataType) || dataType == Date.class || dataType== Instant.class || dataType == Boolean.class || dataType == UUID.class) { return mapping == Mapping.DEFAULT; } else if (AttributeUtil.isString(dataType)) { return mapping == Mapping.DEFAULT || mapping == Mapping.STRING || mapping == Mapping.TEXT || mapping == Mapping.TEXTSTRING; } else if (AttributeUtil.isGeo(dataType)) { return mapping == Mapping.DEFAULT || mapping == Mapping.PREFIX_TREE; } return false; }
private Map<String,Object> getAdditionDoc(KeyInformation.IndexRetriever information, String store, IndexMutation mutation) throws PermanentBackendException { final Map<String,Object> doc = new HashMap<>(); for (final IndexEntry e : mutation.getAdditions()) { final KeyInformation keyInformation = information.get(store).get(e.field); if (keyInformation.getCardinality() == Cardinality.SINGLE) { doc.put(e.field, convertToEsType(e.value, Mapping.getMapping(keyInformation))); if (hasDualStringMapping(keyInformation)) { doc.put(getDualMappingName(e.field), convertToEsType(e.value, Mapping.getMapping(keyInformation))); } } } return doc; }
case SINGLE: value = convertToEsType(Iterators.getLast(add.getValue().iterator()).value, Mapping.getMapping(keyInformation)); break; case SET: case LIST: value = add.getValue().stream() .map(v -> convertToEsType(v.value, Mapping.getMapping(keyInformation))) .filter(v -> { Preconditions.checkArgument(!(v instanceof byte[]),
case SET: case LIST: final String jsValue = convertToJsType(deletion.value, compat.scriptLang(), Mapping.getMapping(keyInformation)); String index = INDEX_NAME + i++; script.append("def ")
KeyInformation information) throws AssertionError, PermanentBackendException, BackendException { final Class<?> dataType = information.getDataType(); Mapping map = Mapping.getMapping(information); final Map<String,Object> properties = new HashMap<>(); if (AttributeUtil.isString(dataType)) {
@Override public boolean supports(KeyInformation information, JanusGraphPredicate predicate) { final Class<?> dataType = information.getDataType(); final Mapping mapping = Mapping.getMapping(information); if (mapping!=Mapping.DEFAULT && !AttributeUtil.isString(dataType) && !(mapping==Mapping.PREFIX_TREE && AttributeUtil.isGeo(dataType))) return false;
@Override public boolean supports(KeyInformation information, JanusGraphPredicate janusgraphPredicate) { final Class<?> dataType = information.getDataType(); final Mapping mapping = Mapping.getMapping(information); if (mapping!=Mapping.DEFAULT && !AttributeUtil.isString(dataType) && !(mapping==Mapping.PREFIX_TREE && AttributeUtil.isGeo(dataType))) return false;
final Mapping map = Mapping.getMapping(information.get(key)); Preconditions.checkArgument(predicate instanceof Geo && predicate != Geo.DISJOINT, "Relation not supported on geo types: " + predicate);
} else throw new IllegalArgumentException("Predicate is not supported for string value: " + predicate); } else if (value instanceof Geoshape && Mapping.getMapping(information.get(key)) == Mapping.DEFAULT) {
BaseTransaction tx) throws BackendException { final Class<?> dataType = information.getDataType(); final Mapping map = Mapping.getMapping(information); Preconditions.checkArgument(map==Mapping.DEFAULT || AttributeUtil.isString(dataType) || (map==Mapping.PREFIX_TREE && AttributeUtil.isGeo(dataType)),
final String order = orderEntry.getOrder().name(); final KeyInformation information = informations.get(query.getStore()).get(orderEntry.getKey()); final Mapping mapping = Mapping.getMapping(information); final Class<?> datatype = orderEntry.getDatatype(); sr.addSort(orderEntry.getKey(), order.toLowerCase(), convertToEsDataType(datatype, mapping));