private BytesRef convertNumber(Number number) {
        if (Integer.class.isInstance(number) || Byte.class.isInstance(number)
                || Short.class.isInstance(number)) {
            BytesRefBuilder ref = new BytesRefBuilder();
            NumericUtils.intToPrefixCoded(number.intValue(), 0, ref);
            return ref.get();
        } else if (Double.class.isInstance(number)
                || BigDecimal.class.isInstance(number)) {
            BytesRefBuilder ref = new BytesRefBuilder();
            long l = NumericUtils.doubleToSortableLong(number.doubleValue());
            NumericUtils.longToPrefixCoded(l, 0, ref);
            return ref.get();
        } else if (Long.class.isInstance(number)
                || BigInteger.class.isInstance(number)) {
            BytesRefBuilder ref = new BytesRefBuilder();
            NumericUtils.longToPrefixCoded(number.longValue(), 0, ref);
            return ref.get();
        } else if (Float.class.isInstance(number)) {
            BytesRefBuilder ref = new BytesRefBuilder();
            int i = NumericUtils.floatToSortableInt(number.floatValue());
            NumericUtils.intToPrefixCoded(i, 0, ref);
            return ref.get();
        } else {
            throw new IllegalArgumentException("Unsupported numeric type "
                    + number.getClass().getName());
        }
    }
If the query is a BooleanQuery and it contains a single Occur.MUST_NOT
clause it will be returned as is. Otherwise it will be wrapped in a
BooleanClause with the given Occur.
querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneSerializer.java