vespa icon indicating copy to clipboard operation
vespa copied to clipboard

Is there Java Query API?

Open Heezer opened this issue 1 year ago • 8 comments

Required is something like Feed Client - https://docs.vespa.ai/en/vespa-feed-client.html, which works totally fine for me!

Until now I cannot find any Vespa API / Client which does operations described on https://docs.vespa.ai/en/query-api.html and https://docs.vespa.ai/en/nearest-neighbor-search.html.

Thanks in advance!

Heezer avatar Aug 11 '23 09:08 Heezer

See #24534 for more details - thanks!

kkraune avatar Aug 11 '23 11:08 kkraune

See #24534 for more details - thanks!

ok, thanks for reply. If I understood you correctly, you suggest to write own client, right?

If so, this is exactly what I wanted to avoid 😄 Since the common things like HTTP SSL client with PEM key & cert (at least!!) should be centralized as simple vespa client IMO. Actually the most of the code is already done and is inside of vespa-feed-client.

What do you think guys?

Heezer avatar Aug 11 '23 12:08 Heezer

Yes, you're right. We have not prioritized this because the query side is so simple, but key/cert handling complicates things a bit so this might be worth while now.

bratseth avatar Aug 14 '23 09:08 bratseth

Publish sample java code using mTLS

johans1 avatar Aug 16 '23 12:08 johans1

I got this working by using library - https://github.com/Hakky54/sslcontext-kickstart#using-pem-files. Let me know if this is not taken - I can raise a PR

public SimpleHttpClient(String host, String certificate, String privateKey) {
        logger.info(">>>>>>>>>>>>\t\tSimpleHttpClient Constructor certificate {} for {}", certificate, host);
        X509ExtendedKeyManager keyManagerSTR = PemUtils.parseIdentityMaterial(certificate, privateKey, "secret".toCharArray());
        SSLFactory sslFactory = SSLFactory.builder()
                .withIdentityMaterial(keyManagerSTR)
                .withDefaultTrustMaterial()
                .build();

        httpClient = HttpClientBuilder.create().setSSLContext(sslFactory.getSslContext()).build();
        this.host = host;
    }

ketankhairnar avatar Sep 03 '23 08:09 ketankhairnar

@ketankhairnar We intend to create a new or extend an existing example in https://github.com/vespa-engine/sample-apps. Feel free to submit a contribution there.

bjorncs avatar Sep 04 '23 13:09 bjorncs

@ketankhairnar FYI https://blog.vespa.ai/announce-tokens-and-anonymous-endpoints/#data-plane-token-authentication

bjorncs avatar Jan 10 '24 13:01 bjorncs

Thanks @bjorncs

ketankhairnar avatar Jan 17 '24 14:01 ketankhairnar