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

[BUG] Fix "View Single Document" & "View Surrounding Documents" links for PPL/SQL Queries #8551

Open
LDrago27 opened this issue Oct 10, 2024 · 1 comment
Labels
bug Something isn't working discover for discover reinvent

Comments

@LDrago27
Copy link
Collaborator

LDrago27 commented Oct 10, 2024

Describe the bug

Currently we are hiding the "View Single Document" & "View Surrounding Documents" links for PPL/SQL Queries. These links are broken for above.

doclinks generated for the PPL/SQL have id as undefined . (Sample doc link)
/app/discover#/doc/d3d7af60-4c81-11e8-b3d7-01146121b73d/d3d7af60-4c81-11e8-b3d7-01146121b73d?id=undefined

useEffect(() => {
    async function requestData() {
      try {
        const indexPatternEntity = await indexPatternService.get(indexPatternId);
        setIndexPattern(indexPatternEntity);
        const { rawResponse } = await getServices()
          .data.search.search(
            {
              dataSourceId: indexPatternEntity.dataSourceRef?.id,
              params: {
                index,
                body: buildSearchBody(id, indexPatternEntity),
              },
            },
            {
              withLongNumeralsSupport: true,
            }
          )
          .toPromise();

        const hits = rawResponse.hits;

        if (hits?.hits?.[0]) {
          setStatus(OpenSearchRequestState.Found);
          setHit(hits.hits[0]);
        } else {
          setStatus(OpenSearchRequestState.NotFound);
        }
      } catch (err) {
        if (err.savedObjectId) {
          setStatus(OpenSearchRequestState.NotFoundIndexPattern);
        } else if (err.status === 404) {
          setStatus(OpenSearchRequestState.NotFound);
        } else {
          setStatus(OpenSearchRequestState.Error);
        }
      }
    }
    requestData();
  }, [id, index, indexPatternId, indexPatternService]);
  return [status, hit, indexPattern];

body: buildSearchBody(id, indexPatternEntity) is trying to build a body with an undefined id . Also the search performed is a DQL search irrespective of the language/dataset selected by user which cause the search API call to be broken by datasets that don't support DQL languages (for example: Indexes and S3 Tables)

Steps to Reproduce

  1. git revert 36debc8
  2. Navigate to Discover
  3. Change the language to PPL/SQL and run the query
  4. Expand any of the documents in the results
  5. Click on the View Surrounding Documents or View Single Document Link in the expanded document

Expected behavior
The functionality of "View Single Document" & "View Surrounding Documents" should work irrespective of the language and dataset selected.

OpenSearch Version
6.0.0
Dashboards Version
3.0.0

Plugins

Please list all plugins currently enabled.

Screenshots

If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Browser and version [e.g. 22]

Additional context

Add any other context about the problem here.

@LDrago27 LDrago27 added bug Something isn't working untriaged labels Oct 10, 2024
@ananzh ananzh added discover-next discover for discover reinvent and removed discover-next labels Oct 11, 2024
@ananzh
Copy link
Member

ananzh commented Oct 15, 2024

I think it is a missing function for PPL/SQL. There is no document id to fetch. data.search.search is only for DQL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working discover for discover reinvent
Projects
None yet
Development

No branches or pull requests

3 participants