Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v1-google-cloud-discoveryengine]: Still receiving as gRpc struct even use HttpJsonTransportProvider #10971

Open
birbbie96 opened this issue Jun 15, 2024 · 2 comments
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.

Comments

@birbbie96
Copy link

birbbie96 commented Jun 15, 2024

First of all, I'm very new with this service google-cloud-discoveryengine.
I trying to call https://discoveryengine.googleapis.com/v1 for vertex search with client lib from google cloud and i want the result as json, btw i always receive struct which is not json response. So i go to read this documentation https://cloud.google.com/java/docs/reference/google-cloud-discoveryengine/latest/com.google.cloud.discoveryengine.v1.SearchServiceClient, they said that use
SearchServiceSettings searchServiceSettings = SearchServiceSettings.newHttpJsonBuilder().build();
but i still get struct response.

can u help me solve this problem? or tell me what i did wrong
this is my code

    SearchServiceSettings searchServiceSettings = SearchServiceSettings.newHttpJsonBuilder().build();
    try (SearchServiceClient searchServiceClient = SearchServiceClient.create(searchServiceSettings)) {
        SearchRequest request =
                SearchRequest.newBuilder()
                        .setServingConfig(
                                ServingConfigName.formatProjectLocationCollectionDataStoreServingConfigName(
                                        projectId, location, collectionId, dataStoreId, servingConfigId))
                        .setSpellCorrectionSpec(
                                SearchRequest.SpellCorrectionSpec.newBuilder()
                                        .setMode(SearchRequest.SpellCorrectionSpec.Mode.AUTO).build()
                        )
                        .setQueryExpansionSpec(
                                SearchRequest.QueryExpansionSpec.newBuilder()
                                        .setCondition(SearchRequest.QueryExpansionSpec.Condition.AUTO).build()
                        )
                        .setQuery(searchQuery)
                        .setPageSize(1)
                        .build();
        SearchServiceClient.SearchPagedResponse a =  searchServiceClient.search(request);
        SearchResponse response = a.getPage().getResponse();
        List<SearchResponse.SearchResult> results = response.getResultsList();
        SearchResponse.SearchResult res = results.getFirst();

this is some part of my response

results {
  id: "1250"
  document {
    name: "projects/272270411648/locations/global/collections/default_collection/dataStores/mordee-doctor-info-test/branches/0/documents/1250"
    id: "1250"
    struct_data {
      fields {
        key: "availableChannels"
        value {
          list_value {
            values {
              string_value: "Video"
            }
            values {
              string_value: "Voice"
            }
          }
        }
      }
      fields {
        key: "availableLanguages"
        value {
          list_value {
            values {
              string_value: "th-TH"
            }
          }
        }
      }
      fields {
        key: "certificate"
        value {
          struct_value {
            fields {
              key: "en"
              value {
                string_value: "Bachelor of Science Program in Food Technology and Nutrition, Mahasarakham University "
              }
            }
            fields {
              key: "th"
              value {
                string_value: "Master of Science Program in Food Technology, Khonkaen University "
              }
            }
          }
        }
      }

note* i try v1, v1beta, and v1alpha already

Java Version: java 22.0.1
Quarkus Version: 3.11.1

Thanks!

@alicejli alicejli added type: question Request for information or clarification. Not an issue. priority: p3 Desirable enhancement or fix. May not be included in next release. labels Jun 20, 2024
@suztomo
Copy link
Member

suztomo commented Jun 24, 2024

i want the result as json

That "HttpJson" client setting is to specify the underlying communication procotol. From library's API's perspective, you won't see the difference between the underlying gRPC or JSON. Consider the API is the result after JSON parsing was already performed.

@jegaths
Copy link

jegaths commented Jul 1, 2024

Any luck on this? I am also facing similar problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants