public JsonResultSet getSimilarImagesAndIndex(String id, double[] vector, double threshold) {

    	JsonResultSet similar = new JsonResultSet();

        byte[] vectorInBytes = new byte[8 * vector.length];
        ByteBuffer bbuf = ByteBuffer.wrap(vectorInBytes);
        for (double value : vector) {
            bbuf.putDouble(value);
        }

        PostMethod queryMethod = null;
        String response = null;
        try {
            ByteArrayPartSource source = new ByteArrayPartSource("bytes", vectorInBytes);
            Part[] parts = {
            	new StringPart("id", id),
                new FilePart("vector", source),
                new StringPart("threshold", String.valueOf(threshold))
            };

            queryMethod = new PostMethod(webServiceHost + "/rest/visual/qindex/" + collectionName);
            queryMethod.setRequestEntity(new MultipartRequestEntity(parts, queryMethod.getParams()));
            int code = httpClient.executeMethod(queryMethod);
            if (code == 200) {
                InputStream inputStream = queryMethod.getResponseBodyAsStream();
                StringWriter writer = new StringWriter();
                IOUtils.copy(inputStream, writer);
                response = writer.toString();
                queryMethod.releaseConnection();

                similar = parseResponse(response);
            }
        } catch (Exception e) {
        	_logger.error("Exception for vector of length " + vector.length, e);
            response = null;
        } finally {
            if (queryMethod != null) {
                queryMethod.releaseConnection();
            }
        }
        return similar;
    }
public JsonResultSet getSimilarImagesAndIndex ( String id , double [ ] vector , double threshold ) { JsonResultSet similar = new JsonResultSet ( ) ; byte [ ] vectorInBytes = new byte [ 8 * vector . length ] ; ByteBuffer bbuf = ByteBuffer . wrap ( vectorInBytes ) ; for ( double value : vector ) { bbuf . putDouble ( value ) ; } PostMethod queryMethod = null ; String response = null ; try { ByteArrayPartSource source = new ByteArrayPartSource ( "bytes" , vectorInBytes ) ; Part [ ] parts = { new StringPart ( "id" , id ) , new FilePart ( "vector" , source ) , new StringPart ( "threshold" , String . valueOf ( threshold ) ) } ; queryMethod = new PostMethod ( webServiceHost + "/rest/visual/qindex/" + collectionName ) ; queryMethod . setRequestEntity ( new MultipartRequestEntity ( parts , queryMethod . getParams ( ) ) ) ; int code = httpClient . executeMethod ( queryMethod ) ; if ( code == 200 ) { InputStream inputStream = queryMethod . getResponseBodyAsStream ( ) ; StringWriter writer = new StringWriter ( ) ; IOUtils . copy ( inputStream , writer ) ; response = writer . toString ( ) ; queryMethod . releaseConnection ( ) ; similar = parseResponse ( response ) ; } } catch ( Exception e ) { _logger . error ( "Exception for vector of length " + vector . length , e ) ; response = null ; } finally { if ( queryMethod != null ) { queryMethod . releaseConnection ( ) ; } } return similar ; }
Get similar images by vector

@param vector
@param threshold
@return