@Override
    public Query termsQuery(List values, @Nullable QueryShardContext context) {
      if (context == null) {
        return super.termsQuery(values, context);
      }

      List<String> types = new ArrayList<>(context.getMapperService().types().size());
      for (DocumentMapper documentMapper : context.getMapperService().docMappers(false)) {
        if (!documentMapper.parentFieldMapper().active()) {
          types.add(documentMapper.type());
        }
      }

      List<BytesRef> bValues = new ArrayList<>(values.size());
      for (Object value : values) {
        BytesRef bValue = BytesRefs.toBytesRef(value);
        if (Uid.hasDelimiter(bValue)) {
          bValues.add(bValue);
        } else {
          // we use all non child types, cause we don't know if its exact or not...
          for (String type : types) {
            bValues.add(Uid.createUidAsBytes(type, bValue));
          }
        }
      }
      return new TermsQuery(name(), bValues);
    }
 @Override
 public BytesRef indexedValueForSearch(Object value) {
   if (value instanceof BytesRef) {
     BytesRef bytesRef = (BytesRef) value;
     if (Uid.hasDelimiter(bytesRef)) {
       return bytesRef;
     }
     return Uid.createUidAsBytes(typeAsBytes, bytesRef);
   }
   String sValue = value.toString();
   if (sValue.indexOf(Uid.DELIMITER) == -1) {
     return Uid.createUidAsBytes(type, sValue);
   }
   return super.indexedValueForSearch(value);
 }