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

Adds the Fields field containing the document fields to the SearchHit struct #508

Merged

Conversation

thekogo
Copy link
Contributor

@thekogo thekogo commented Apr 4, 2024

Description

Add fields fields in SearchHit for support mapping response with fields key

Issues Resolved

For support retrieve specific fields in the search response
Request

{
  "query": {
    "match": {
      "username": "thekogo"
    }
  },
  "fields": [
    "username",
    "email"
  ],
  "_source": false
}

Response (add mapping for support this response)

{
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "index-001",
        "_id" : "0",
        "_score" : 1.0,
        "fields" : {
          "username" : [
            "thekogo"
          ],
          "email" : [
            "admin@gmail.com"
          ]
        }
      }
    ]
  }
}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link

codecov bot commented Apr 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 57.29%. Comparing base (392013b) to head (7fa967d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #508   +/-   ##
=======================================
  Coverage   57.29%   57.29%           
=======================================
  Files         315      315           
  Lines        9823     9823           
=======================================
  Hits         5628     5628           
  Misses       2902     2902           
  Partials     1293     1293           
Flag Coverage Δ
integration 50.83% <ø> (ø)
unit 12.84% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
opensearchapi/api_search.go 100.00% <ø> (ø)

Copy link
Collaborator

@VachaShah VachaShah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @thekogo for your contribution!

A few comments:

  1. Could we also add a test for the new field? https://github.com/opensearch-project/opensearch-go/blob/main/opensearchapi/api_search_test.go
  2. Please add a CHANGELOG entry.

opensearchapi/api_search.go Show resolved Hide resolved
VachaShah
VachaShah previously approved these changes Apr 4, 2024
@VachaShah
Copy link
Collaborator

Can you please signoff your commits? You can amend your commits using `git commit --amend -s" to sign them off. https://github.com/opensearch-project/opensearch-go/blob/main/CONTRIBUTING.md#developer-certificate-of-origin

@thekogo thekogo force-pushed the add-fields-in-search-hit branch from ab30c94 to e95f8d3 Compare April 4, 2024 18:19
@thekogo thekogo changed the title add fields json.RawMessage in SearchHit Adds the Fields field containing the document fields to the SearchHit struct Apr 4, 2024
@thekogo thekogo changed the title Adds the Fields field containing the document fields to the SearchHit struct Adds the field fields containing the document fields to the SearchHit struct Apr 4, 2024
@thekogo thekogo changed the title Adds the field fields containing the document fields to the SearchHit struct Adds the Fields field containing the document fields to the SearchHit struct Apr 4, 2024
@thekogo thekogo force-pushed the add-fields-in-search-hit branch from e95f8d3 to 6ebb1d8 Compare April 4, 2024 18:31
…Hit` struct

Signed-off-by: Ponlawat Suparat <thekogo@gmail.com>
@thekogo
Copy link
Contributor Author

thekogo commented Apr 4, 2024

Sorry I'm not sure why Lint check / Prettify (pull_request) error with

Run npm i -g npm@8 && npm i -g prettier
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/share/man/man5
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/share/man/man5'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/share/man/man5'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/share/man/man5'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in: /home/runner/.npm/_logs/2024-04-04T18_42_12_[7](https://github.com/opensearch-project/opensearch-go/actions/runs/8559713019/job/23457055244?pr=508#step:3:8)53Z-debug-0.log
Error: Process completed with exit code 243.

Copy link
Collaborator

@VachaShah VachaShah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was able to get a clean run for prettify. Looks like some intermittent issue.

@VachaShah VachaShah merged commit f3ad333 into opensearch-project:main Apr 4, 2024
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants