GithubHelp home page GithubHelp logo

opensearch-project / opensearch-go Goto Github PK

View Code? Open in Web Editor NEW
184.0 184.0 92.0 4.85 MB

Go Client for OpenSearch

Home Page: https://opensearch.org/docs/latest/clients/go/

License: Apache License 2.0

Makefile 0.74% Go 99.26%

opensearch-go's People

Contributors

anaethelion avatar axw avatar dblock avatar dependabot[bot] avatar dzyanis avatar harrisonhjones avatar igungor avatar jakob3xd avatar karmi avatar kiivihal avatar kotaroooo0 avatar matelang avatar mend-for-github-com[bot] avatar mpdreamz avatar noname4life avatar peterzhuamazon avatar rmasclef avatar sethmlarson avatar swallez avatar szabosteve avatar tannerjones4075 avatar tokesh avatar tty2 avatar vachashah avatar vijayanb avatar xd-deng avatar xtansia avatar yuyaabo avatar zethuman avatar zhang-jie-jun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opensearch-go's Issues

[FEATURE] Add IAM authentication option

If people want to connect to an Amazon OpenSearch Service cluster, they have to figure out how to use this client alongside some third-party signing library and/or the AWS SDK, which is non-trivial due to how we (by design) conceal the underlying HTTP requests that the client makes. We should offer IAM signing as an option, just like the OpenSearch CLI does.

Is your feature request related to a problem?
If you want to use this client with an Amazon OpenSearch Service cluster that has IAM authentication rather than basic authentication, good luck.

What solution would you like?

When initializing the client, an AuthType option. If basic (or null), accept username and password. If IAM, accept options for access key, secret key, session token, region, and service.

What alternatives have you considered?

An additional Go IAM signing library for use on top of the client. But given that it would only work with the client, it seems better and easier to just add it to the client.

Do you have any additional context?

opensearch-project/OpenSearch#1400

CVE-2021-38561 (High) detected in github.com/golang/text-v0.3.6 - autoclosed

CVE-2021-38561 - High Severity Vulnerability

Vulnerable Library - github.com/golang/text-v0.3.6

[mirror] Go text processing support

Dependency Hierarchy:

  • github.com/aws/aws-sdk-go-v1.42.27 (Root Library)
    • github.com/golang/net/go.mod-4163338589ed626ba11276b63facaef1f55349d4
      • github.com/golang/text-v0.3.6 (Vulnerable Library)

Found in HEAD commit: 3f3ab782590b20cf59f880bfdbd70556a225006e

Found in base branch: main

Vulnerability Details

Due to improper index calculation, an incorrectly formatted language tag can cause Parse
to panic, due to an out of bounds read. If Parse is used to process untrusted user inputs,
this may be used as a vector for a denial of service attack.

Publish Date: 2021-08-12

URL: CVE-2021-38561

CVSS 3 Score Details (7.5)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: None
    • Integrity Impact: None
    • Availability Impact: High

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: https://osv.dev/vulnerability/GO-2021-0113

Release Date: 2021-08-12

Fix Resolution: v0.3.7

Milestone 1 tasks

In this milestone, we focus on setting up main branch that can work with existing 7.10.2 version of ODFE

  • Delete all older branches < 7.10
  • Delete all released tags
  • Delete main branch(this branch potentially tracks of all 8.x features as well)
  • create main branch from 7.x branch
  • Remove product checker commit if present (this is required to make clients work with oss cluster)
  • Copy template files related to OpenSearch guidelines.
  • set up CI and ensure tests pass for Elasticsearch OSS Docker image. This means all the test cases related to oss features from 7.10.2 executes successfully.

Add status badge

Add badge for

  1. unit test
  2. integration test
  3. build
  4. codecov
  5. PR
  6. chat

[PROPOSAL] Use with golang Elastic Search equivalent

** What kind of business use case are you trying to solve? What are your requirements?

Need golang server to have more control over our destiny and hate the JVM ( sorry )

What is the problem? What is preventing you from meeting the requirements?

We are golang coders in the team and so using a golang server is much easier.

What are you proposing? What do you suggest we do to solve the problem or improve the existing situation?

THIS: https://github.com/prabhatsharma/zinc

Its taking off. Does not have clustering yet
but there is another clustered one here https://github.com/mosuka/phalanx, but it needs the ziny APi on top of it.

What are your assumptions or prerequisites?

Dont think i am assuming much. but i probably dont know what i dont know.

What are remaining open questions?

i would like to know if this interests the community.
I can put time into it, but it would be nice to know if others like this idea and is they also want to get involved.

CVE-2015-9251 (Medium) detected in golang.org/x/tools-v0.1.12

CVE-2015-9251 - Medium Severity Vulnerability

Vulnerable Library - golang.org/x/tools-v0.1.12

Library home page: https://proxy.golang.org/golang.org/x/tools/@v/v0.1.12.zip

Dependency Hierarchy:

  • golang.org/x/tools-v0.1.12 (Vulnerable Library)

Found in HEAD commit: 3f3ab782590b20cf59f880bfdbd70556a225006e

Found in base branch: main

Vulnerability Details

jQuery before 3.0.0 is vulnerable to Cross-site Scripting (XSS) attacks when a cross-domain Ajax request is performed without the dataType option, causing text/javascript responses to be executed.

Publish Date: 2018-01-18

URL: CVE-2015-9251

CVSS 3 Score Details (6.1)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: Required
    • Scope: Changed
  • Impact Metrics:
    • Confidentiality Impact: Low
    • Integrity Impact: Low
    • Availability Impact: None

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: https://nvd.nist.gov/vuln/detail/CVE-2015-9251

Release Date: 2018-01-18

Fix Resolution: jQuery - 3.0.0

[BUG] UpdateRequest never update.

What is the bug?
the api.update.go using wrong HTTP request path.

How can one reproduce the bug?
Steps to reproduce the behavior: create UpdateRequest and execute it.

What is the expected behavior?
Swap line 101 & 103 of "opensearchapi/api.update.go".

What is your host/environment?

  • OS: macos
  • Version 12
  • Plugins

Do you have any screenshots?
None.

Do you have any additional context?
None

CVE-2022-27191 (High) detected in golang.org/x/crypto-v0.0.0-20210921155107-089bfa567519 - autoclosed

CVE-2022-27191 - High Severity Vulnerability

Vulnerable Library - golang.org/x/crypto-v0.0.0-20210921155107-089bfa567519

Library home page: https://proxy.golang.org/golang.org/x/crypto/@v/v0.0.0-20210921155107-089bfa567519.zip

Dependency Hierarchy:

  • golang.org/x/crypto-v0.0.0-20210921155107-089bfa567519 (Vulnerable Library)

Found in HEAD commit: 3f3ab782590b20cf59f880bfdbd70556a225006e

Found in base branch: main

Vulnerability Details

The golang.org/x/crypto/ssh package before 0.0.0-20220314234659-1baeb1ce4c0b for Go allows an attacker to crash a server in certain circumstances involving AddHostKey.

Publish Date: 2022-03-18

URL: CVE-2022-27191

CVSS 3 Score Details (7.5)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: None
    • Integrity Impact: None
    • Availability Impact: High

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: https://nvd.nist.gov/vuln/detail/CVE-2022-27191

Release Date: 2022-03-18

Fix Resolution: golang-golang-x-crypto-dev - 1:0.0~git20220315.3147a52-1;golang-go.crypto-dev - 1:0.0~git20220315.3147a52-1

Milestone 2 tasks

In this milestone, we focus on cleaning up existing code and make it ready for OpenSearch development

  • Remove X-Pack and non oss features/tests
  • Remove docs
  • Remove commits not related to >7.10 from main branch
  • Update CI to run with OpenDistro docker image with out security plugin

Support OpenTracing Instrumentation

Hi, We have a problem with opensearch-go client but we can't find it so we want to instrument the client in order to improve the observability. Is there an easy way to achieve that goal? Except forking the project and adding instrumentation to the forked version and using it.

[FEATURE] Types for ISM in opensearchapi

Is your feature request related to a problem?
Currently there's no support for the ISM APIs in opensearchapi. This means to use that feature you need to manually extend the API yourself

What solution would you like?
It would be nice if this was included.

What alternatives have you considered?
Currently we have written our own implementation.

CVE-2021-43565 (High) detected in golang.org/x/crypto-v0.0.0-20210921155107-089bfa567519 - autoclosed

CVE-2021-43565 - High Severity Vulnerability

Vulnerable Library - golang.org/x/crypto-v0.0.0-20210921155107-089bfa567519

Library home page: https://proxy.golang.org/golang.org/x/crypto/@v/v0.0.0-20210921155107-089bfa567519.zip

Dependency Hierarchy:

  • golang.org/x/crypto-v0.0.0-20210921155107-089bfa567519 (Vulnerable Library)

Found in HEAD commit: 3f3ab782590b20cf59f880bfdbd70556a225006e

Found in base branch: main

Vulnerability Details

The x/crypto/ssh package before 0.0.0-20211202192323-5770296d904e of golang.org/x/crypto allows an attacker to panic an SSH server.

Publish Date: 2022-09-06

URL: CVE-2021-43565

CVSS 3 Score Details (7.5)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: None
    • Integrity Impact: None
    • Availability Impact: High

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: https://nvd.nist.gov/vuln/detail/CVE-2021-43565

Release Date: 2021-11-10

Fix Resolution: golang-golang-x-crypto-dev - 1:0.0~git20211202.5770296-1;golang-go.crypto-dev - 1:0.0~git20211202.5770296-1

Release v1.1.0

Second minor release

  • Create 1.1 branch
  • Generate release notes
  • Create release tag

How to query document by index

Hi all, i am new here and asking for some help .I query my documents by code below (golang), but it would search from all the index, how should i change the queryString to make that onle searching with setted index

queryString := `{
		"size": 1,
		"query": {
			"multi_match": {
			"query": "{name}",
			"fields": ["{fields}"]
			}
	    }
	}`
queryString = strings.Replace(queryString, "{name}", fmt.Sprintf("%v", "person1_login"), -1)
queryString = strings.Replace(queryString, "{"+"fields"+"}", fmt.Sprintf("%v", "user_login"), -1)
content := strings.NewReader(queryString)

search := opensearchapi.SearchRequest{
Body: content,
}

Any advices would be appreciated, thanks.

[FEATURE] Support version and routing fields in bulk indexer

Is your feature request related to a problem?
Currently the bulk index request structs do not support the version or routing options.

What solution would you like?
Let's add these fields to the structs and update the writer to build the json correctly.

What alternatives have you considered?
I'm not sure there are any, with how the current implementation of the bulk indexer works we're unable to set these fields unless they are available on the structs.

Do you have any additional context?
https://opensearch.org/docs/opensearch/rest-api/document-apis/index-document/ the version, routing, and version_type fields are the ones requested

Accept either ELASTICSEARCH_URL or OPENSEARCH_URL

To support backward compatibility, if addresses are not specified in config during new client api, we will look for addresses either from ELASTICSEARCH_URL or OPENSEARCH_URL environment variable. if we find both, then will exit with error message that both can't be set .

CVE-2022-28948 (Medium) detected in github.com/go-yaml/yaml-v2.4.0 - autoclosed

CVE-2022-28948 - Medium Severity Vulnerability

Vulnerable Library - github.com/go-yaml/yaml-v2.4.0

YAML support for the Go language.

Dependency Hierarchy:

  • github.com/go-yaml/yaml-v2.4.0 (Vulnerable Library)

Found in HEAD commit: 3f3ab782590b20cf59f880bfdbd70556a225006e

Found in base branch: main

Vulnerability Details

An issue in the Unmarshal function in Go-Yaml v3 causes the program to crash when attempting to deserialize invalid input.

Publish Date: 2022-05-19

URL: CVE-2022-28948

CVSS 3 Score Details (5.5)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Local
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: Required
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: None
    • Integrity Impact: None
    • Availability Impact: High

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: GHSA-fm53-mpmp-7qw2

Release Date: 2022-05-19

Fix Resolution: v3.0.0

Release version 2.0.0 for Go client

Release the client version 2.0.0. Before releasing, the following items need to be done:

  • Add OpenSearch 2.0 to the integration test matrix.
  • Bump the client version to 2.0.0.
  • Cut a 2.0 branch for the client.

[PROPOSAL / QUESTION] Is there a plan to improve usability by making the API more idiomatic to the Go ecosystem?

What kind of business use case are you trying to solve? What are your requirements?

Hi. First, thank you for releasing this client.

I had been using the original one for the last couple of weeks and I noticed that it uses some patterns (like) that aren't so commonly found on Go clients (generated or not).

I imagine that having a leaner API using a more traditional (as in Go idiomatic) approach would be a good thing, at least for casual API consumers that are primarily Go developers – although I'm not so sure about people with plenty of experience using OpenSearch.

What is the problem? What is preventing you from meeting the requirements?
Let me try to give you a concrete example:

I imported the package to my code for the first time, and then I started looking around to see how I could do what I needed.
I quickly discovered that I needed to instantiate a client by calling opensearch.NewClient.

Then, the next thing I discovered was the Search function there, except that I immediately got confused as to why it was defined in the confusing API struct in an oddly named api._.go file.

type API struct {
Cat *Cat
Cluster *Cluster
Indices *Indices
Ingest *Ingest
Nodes *Nodes
Remote *Remote
Snapshot *Snapshot
Tasks *Tasks
Bulk Bulk
ClearScroll ClearScroll
Count Count
Create Create
DanglingIndicesDeleteDanglingIndex DanglingIndicesDeleteDanglingIndex
DanglingIndicesImportDanglingIndex DanglingIndicesImportDanglingIndex
DanglingIndicesListDanglingIndices DanglingIndicesListDanglingIndices
DeleteByQuery DeleteByQuery
DeleteByQueryRethrottle DeleteByQueryRethrottle
Delete Delete
DeleteScript DeleteScript
Exists Exists
ExistsSource ExistsSource
Explain Explain
FieldCaps FieldCaps
Get Get
GetScriptContext GetScriptContext
GetScriptLanguages GetScriptLanguages
GetScript GetScript
GetSource GetSource
Index Index
Info Info
Mget Mget
Msearch Msearch
MsearchTemplate MsearchTemplate
Mtermvectors Mtermvectors
Ping Ping
PutScript PutScript
RankEval RankEval
Reindex Reindex
ReindexRethrottle ReindexRethrottle
RenderSearchTemplate RenderSearchTemplate
ScriptsPainlessExecute ScriptsPainlessExecute
Scroll Scroll
Search Search
SearchShards SearchShards
SearchTemplate SearchTemplate
TermsEnum TermsEnum
Termvectors Termvectors
UpdateByQuery UpdateByQuery
UpdateByQueryRethrottle UpdateByQueryRethrottle
Update Update
}

and I started looking for usage examples just after I noticed the following

type Search func(o ...func(*SearchRequest)) (*Response, error)

and then I discovered there are functions defined on top of this SearchRequest type

// WithContext sets the request context.
//
func (f Search) WithContext(v context.Context) func(*SearchRequest) {
return func(r *SearchRequest) {
r.ctx = v
}
}
// WithBody - The search definition using the Query DSL.
//
func (f Search) WithBody(v io.Reader) func(*SearchRequest) {
return func(r *SearchRequest) {
r.Body = v
}
}
// WithIndex - a list of index names to search; use _all to perform the operation on all indices.
//
func (f Search) WithIndex(v ...string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.Index = v
}
}
// WithDocumentType - a list of document types to search; leave empty to perform the operation on all types.
//
func (f Search) WithDocumentType(v ...string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.DocumentType = v
}
}
// WithAllowNoIndices - whether to ignore if a wildcard indices expression resolves into no concrete indices. (this includes `_all` string or when no indices have been specified).
//
func (f Search) WithAllowNoIndices(v bool) func(*SearchRequest) {
return func(r *SearchRequest) {
r.AllowNoIndices = &v
}
}
// WithAllowPartialSearchResults - indicate if an error should be returned if there is a partial search failure or timeout.
//
func (f Search) WithAllowPartialSearchResults(v bool) func(*SearchRequest) {
return func(r *SearchRequest) {
r.AllowPartialSearchResults = &v
}
}
// WithAnalyzer - the analyzer to use for the query string.
//
func (f Search) WithAnalyzer(v string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.Analyzer = v
}
}
// WithAnalyzeWildcard - specify whether wildcard and prefix queries should be analyzed (default: false).
//
func (f Search) WithAnalyzeWildcard(v bool) func(*SearchRequest) {
return func(r *SearchRequest) {
r.AnalyzeWildcard = &v
}
}
// WithBatchedReduceSize - the number of shard results that should be reduced at once on the coordinating node. this value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large..
//
func (f Search) WithBatchedReduceSize(v int) func(*SearchRequest) {
return func(r *SearchRequest) {
r.BatchedReduceSize = &v
}
}
// WithCcsMinimizeRoundtrips - indicates whether network round-trips should be minimized as part of cross-cluster search requests execution.
//
func (f Search) WithCcsMinimizeRoundtrips(v bool) func(*SearchRequest) {
return func(r *SearchRequest) {
r.CcsMinimizeRoundtrips = &v
}
}
// WithDefaultOperator - the default operator for query string query (and or or).
//
func (f Search) WithDefaultOperator(v string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.DefaultOperator = v
}
}
// WithDf - the field to use as default where no field prefix is given in the query string.
//
func (f Search) WithDf(v string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.Df = v
}
}
// WithDocvalueFields - a list of fields to return as the docvalue representation of a field for each hit.
//
func (f Search) WithDocvalueFields(v ...string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.DocvalueFields = v
}
}
// WithExpandWildcards - whether to expand wildcard expression to concrete indices that are open, closed or both..
//
func (f Search) WithExpandWildcards(v string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.ExpandWildcards = v
}
}
// WithExplain - specify whether to return detailed information about score computation as part of a hit.
//
func (f Search) WithExplain(v bool) func(*SearchRequest) {
return func(r *SearchRequest) {
r.Explain = &v
}
}
// WithFrom - starting offset (default: 0).
//
func (f Search) WithFrom(v int) func(*SearchRequest) {
return func(r *SearchRequest) {
r.From = &v
}
}
// WithIgnoreThrottled - whether specified concrete, expanded or aliased indices should be ignored when throttled.
//
func (f Search) WithIgnoreThrottled(v bool) func(*SearchRequest) {
return func(r *SearchRequest) {
r.IgnoreThrottled = &v
}
}
// WithIgnoreUnavailable - whether specified concrete indices should be ignored when unavailable (missing or closed).
//
func (f Search) WithIgnoreUnavailable(v bool) func(*SearchRequest) {
return func(r *SearchRequest) {
r.IgnoreUnavailable = &v
}
}
// WithLenient - specify whether format-based query failures (such as providing text to a numeric field) should be ignored.
//
func (f Search) WithLenient(v bool) func(*SearchRequest) {
return func(r *SearchRequest) {
r.Lenient = &v
}
}
// WithMaxConcurrentShardRequests - the number of concurrent shard requests per node this search executes concurrently. this value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests.
//
func (f Search) WithMaxConcurrentShardRequests(v int) func(*SearchRequest) {
return func(r *SearchRequest) {
r.MaxConcurrentShardRequests = &v
}
}
// WithMinCompatibleShardNode - the minimum compatible version that all shards involved in search should have for this request to be successful.
//
func (f Search) WithMinCompatibleShardNode(v string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.MinCompatibleShardNode = v
}
}
// WithPreference - specify the node or shard the operation should be performed on (default: random).
//
func (f Search) WithPreference(v string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.Preference = v
}
}
// WithPreFilterShardSize - a threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. this filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint..
//
func (f Search) WithPreFilterShardSize(v int) func(*SearchRequest) {
return func(r *SearchRequest) {
r.PreFilterShardSize = &v
}
}
// WithQuery - query in the lucene query string syntax.
//
func (f Search) WithQuery(v string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.Query = v
}
}
// WithRequestCache - specify if request cache should be used for this request or not, defaults to index level setting.
//
func (f Search) WithRequestCache(v bool) func(*SearchRequest) {
return func(r *SearchRequest) {
r.RequestCache = &v
}
}
// WithRestTotalHitsAsInt - indicates whether hits.total should be rendered as an integer or an object in the rest search response.
//
func (f Search) WithRestTotalHitsAsInt(v bool) func(*SearchRequest) {
return func(r *SearchRequest) {
r.RestTotalHitsAsInt = &v
}
}
// WithRouting - a list of specific routing values.
//
func (f Search) WithRouting(v ...string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.Routing = v
}
}
// WithScroll - specify how long a consistent view of the index should be maintained for scrolled search.
//
func (f Search) WithScroll(v time.Duration) func(*SearchRequest) {
return func(r *SearchRequest) {
r.Scroll = v
}
}
// WithSearchType - search operation type.
//
func (f Search) WithSearchType(v string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.SearchType = v
}
}
// WithSeqNoPrimaryTerm - specify whether to return sequence number and primary term of the last modification of each hit.
//
func (f Search) WithSeqNoPrimaryTerm(v bool) func(*SearchRequest) {
return func(r *SearchRequest) {
r.SeqNoPrimaryTerm = &v
}
}
// WithSize - number of hits to return (default: 10).
//
func (f Search) WithSize(v int) func(*SearchRequest) {
return func(r *SearchRequest) {
r.Size = &v
}
}
// WithSort - a list of <field>:<direction> pairs.
//
func (f Search) WithSort(v ...string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.Sort = v
}
}
// WithSource - true or false to return the _source field or not, or a list of fields to return.
//
func (f Search) WithSource(v ...string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.Source = v
}
}
// WithSourceExcludes - a list of fields to exclude from the returned _source field.
//
func (f Search) WithSourceExcludes(v ...string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.SourceExcludes = v
}
}
// WithSourceIncludes - a list of fields to extract and return from the _source field.
//
func (f Search) WithSourceIncludes(v ...string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.SourceIncludes = v
}
}
// WithStats - specific 'tag' of the request for logging and statistical purposes.
//
func (f Search) WithStats(v ...string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.Stats = v
}
}
// WithStoredFields - a list of stored fields to return as part of a hit.
//
func (f Search) WithStoredFields(v ...string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.StoredFields = v
}
}
// WithSuggestField - specify which field to use for suggestions.
//
func (f Search) WithSuggestField(v string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.SuggestField = v
}
}
// WithSuggestMode - specify suggest mode.
//
func (f Search) WithSuggestMode(v string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.SuggestMode = v
}
}
// WithSuggestSize - how many suggestions to return in response.
//
func (f Search) WithSuggestSize(v int) func(*SearchRequest) {
return func(r *SearchRequest) {
r.SuggestSize = &v
}
}
// WithSuggestText - the source text for which the suggestions should be returned.
//
func (f Search) WithSuggestText(v string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.SuggestText = v
}
}
// WithTerminateAfter - the maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early..
//
func (f Search) WithTerminateAfter(v int) func(*SearchRequest) {
return func(r *SearchRequest) {
r.TerminateAfter = &v
}
}
// WithTimeout - explicit operation timeout.
//
func (f Search) WithTimeout(v time.Duration) func(*SearchRequest) {
return func(r *SearchRequest) {
r.Timeout = v
}
}
// WithTrackScores - whether to calculate and return scores even if they are not used for sorting.
//
func (f Search) WithTrackScores(v bool) func(*SearchRequest) {
return func(r *SearchRequest) {
r.TrackScores = &v
}
}
// WithTrackTotalHits - indicate if the number of documents that match the query should be tracked.
//
func (f Search) WithTrackTotalHits(v interface{}) func(*SearchRequest) {
return func(r *SearchRequest) {
r.TrackTotalHits = v
}
}
// WithTypedKeys - specify whether aggregation and suggester names should be prefixed by their respective types in the response.
//
func (f Search) WithTypedKeys(v bool) func(*SearchRequest) {
return func(r *SearchRequest) {
r.TypedKeys = &v
}
}
// WithVersion - specify whether to return document version as part of a hit.
//
func (f Search) WithVersion(v bool) func(*SearchRequest) {
return func(r *SearchRequest) {
r.Version = &v
}
}
// WithPretty makes the response body pretty-printed.
//
func (f Search) WithPretty() func(*SearchRequest) {
return func(r *SearchRequest) {
r.Pretty = true
}
}
// WithHuman makes statistical values human-readable.
//
func (f Search) WithHuman() func(*SearchRequest) {
return func(r *SearchRequest) {
r.Human = true
}
}
// WithErrorTrace includes the stack trace for errors in the response body.
//
func (f Search) WithErrorTrace() func(*SearchRequest) {
return func(r *SearchRequest) {
r.ErrorTrace = true
}
}
// WithFilterPath filters the properties of the response body.
//
func (f Search) WithFilterPath(v ...string) func(*SearchRequest) {
return func(r *SearchRequest) {
r.FilterPath = v
}
}
// WithHeader adds the headers to the HTTP request.
//
func (f Search) WithHeader(h map[string]string) func(*SearchRequest) {
return func(r *SearchRequest) {
if r.Header == nil {
r.Header = make(http.Header)
}
for k, v := range h {
r.Header.Add(k, v)
}
}
}
// WithOpaqueID adds the X-Opaque-Id header to the HTTP request.
//
func (f Search) WithOpaqueID(s string) func(*SearchRequest) {
return func(r *SearchRequest) {
if r.Header == nil {
r.Header = make(http.Header)
}
r.Header.Set("X-Opaque-Id", s)
}
}

which are really decorators(-ish?) on top of the much more idiomatic SearchRequest param:

type SearchRequest struct {
Index []string
DocumentType []string
Body io.Reader
AllowNoIndices *bool
AllowPartialSearchResults *bool
Analyzer string
AnalyzeWildcard *bool
BatchedReduceSize *int
CcsMinimizeRoundtrips *bool
DefaultOperator string
Df string
DocvalueFields []string
ExpandWildcards string
Explain *bool
From *int
IgnoreThrottled *bool
IgnoreUnavailable *bool
Lenient *bool
MaxConcurrentShardRequests *int
MinCompatibleShardNode string
Preference string
PreFilterShardSize *int
Query string
RequestCache *bool
RestTotalHitsAsInt *bool
Routing []string
Scroll time.Duration
SearchType string
SeqNoPrimaryTerm *bool
Size *int
Sort []string
Source []string
SourceExcludes []string
SourceIncludes []string
Stats []string
StoredFields []string
SuggestField string
SuggestMode string
SuggestSize *int
SuggestText string
TerminateAfter *int
Timeout time.Duration
TrackScores *bool
TrackTotalHits interface{}
TypedKeys *bool
Version *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
Header http.Header
ctx context.Context
}

I see several problems with decorator functions like these.

I also noticed that gopls wasn't helping me much discover the API for the library, and I attribute part of the problem to how you're expected to build the code kind indirectly using decorators – making browsing code and documentation slower than it may be.

  • There are other usage complications too, but I feel I need more time using it to share a more thoughtful opinion.

What are you proposing? What do you suggest we do to solve the problem or improve the existing situation?

  • Primarily, remove these functional/decorator functions and make some adjustments to the API to make it feel more like a traditional Go API.
  • Also, improve the high-level documentation (probably after making the API leaner).

In short, my suggestion is to do a clean-up to make the API more idiomatic to the Go ecosystem before releasing a v1 version.
What do you think?

What are your assumptions or prerequisites?
I'm assuming the current API can improve developer experience getting rid of some, apparently unimportant, odd patterns (to the Go programming language), which makes the API itself bigger than it needs to be, and harder to master.

Best regards,
Henrique.

CVE-2020-11022 (Medium) detected in golang.org/x/tools-v0.1.12

CVE-2020-11022 - Medium Severity Vulnerability

Vulnerable Library - golang.org/x/tools-v0.1.12

Library home page: https://proxy.golang.org/golang.org/x/tools/@v/v0.1.12.zip

Dependency Hierarchy:

  • golang.org/x/tools-v0.1.12 (Vulnerable Library)

Found in HEAD commit: 3f3ab782590b20cf59f880bfdbd70556a225006e

Found in base branch: main

Vulnerability Details

In jQuery versions greater than or equal to 1.2 and before 3.5.0, passing HTML from untrusted sources - even after sanitizing it - to one of jQuery's DOM manipulation methods (i.e. .html(), .append(), and others) may execute untrusted code. This problem is patched in jQuery 3.5.0.

Publish Date: 2020-04-29

URL: CVE-2020-11022

CVSS 3 Score Details (6.1)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: Required
    • Scope: Changed
  • Impact Metrics:
    • Confidentiality Impact: Low
    • Integrity Impact: Low
    • Availability Impact: None

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-11022

Release Date: 2020-04-29

Fix Resolution: jQuery - 3.5.0

[BUG] Project Versioning

What is the bug?
The project does not follow the Go versioning requirements of a /v2 being added to the package in the go mod file when the first major version bump occurs. Because of this the client is not usable as adding it to the go.mod file as a dependency results in a failed build due to the version not existing, or being an invalid version because the package doesn't contain a /v2 at the end. Even adding the +incompatible does not seem to fix it.

How can one reproduce the bug?
Steps to reproduce the behavior:
Create a project and add this project as a dependency
run go mod tidy

What is the expected behavior?
Go dependency management will fail to find the project and fail the build

What is your host/environment?

  • OS: Darwin
  • Version Latest
  • Plugins

Do you have any screenshots?
If applicable, add screenshots to help explain your problem.
no but can get some if needed adding exact wording of error message.
server response: not found: github.com/opensearch-project/[email protected]+incompatible: invalid version: module contains a go.mod file, so module path must match major version ("github.com/opensearch-project/opensearch-go/v2")

Do you have any additional context?
no

CVE-2012-6708 (Medium) detected in golang.org/x/tools-v0.1.12

CVE-2012-6708 - Medium Severity Vulnerability

Vulnerable Library - golang.org/x/tools-v0.1.12

Library home page: https://proxy.golang.org/golang.org/x/tools/@v/v0.1.12.zip

Dependency Hierarchy:

  • golang.org/x/tools-v0.1.12 (Vulnerable Library)

Found in HEAD commit: 3f3ab782590b20cf59f880bfdbd70556a225006e

Found in base branch: main

Vulnerability Details

jQuery before 1.9.0 is vulnerable to Cross-site Scripting (XSS) attacks. The jQuery(strInput) function does not differentiate selectors from HTML in a reliable fashion. In vulnerable versions, jQuery determined whether the input was HTML by looking for the '<' character anywhere in the string, giving attackers more flexibility when attempting to construct a malicious payload. In fixed versions, jQuery only deems the input to be HTML if it explicitly starts with the '<' character, limiting exploitability only to attackers who can control the beginning of a string, which is far less common.

Publish Date: 2018-01-18

URL: CVE-2012-6708

CVSS 3 Score Details (6.1)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: Required
    • Scope: Changed
  • Impact Metrics:
    • Confidentiality Impact: Low
    • Integrity Impact: Low
    • Availability Impact: None

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: https://nvd.nist.gov/vuln/detail/CVE-2012-6708

Release Date: 2018-01-18

Fix Resolution: jQuery - v1.9.0

[FEATURE] Support for AWS GoLang SDK v2 request signer

Is your feature request related to a problem?
AWS has released v2 of their GoLang SDK. OpenSearch Go already has support for AWS SDK v1, but no support for this newer SDK. Users of SDK v2 thus have to add SDK v1 as a dependency if they want to use OpenSearch Go.

What solution would you like?
A signer only using v2 SDK imports to be added.

What alternatives have you considered?
No alternatives.

Do you have any additional context?
No additional context.

[BUG] Extreme latency in BulkIndexer

What is the bug?
It seems that with a BulkIndexer with 2 workers, I am getting unexpected latency on BulkIndexer.Add(). It seems that somehow the workers are not consuming the queue within any reasonable sort of timeframe, I'm seeing delays of over 20s!

For example, in the last hour I've 53 cases of >1s latency on just Add() out of a total of 174 calls.

How can one reproduce the bug?
With 2 workers running, adding items from different goroutines and a relatively busy search cluster.

What is the expected behavior?
Sub-millisecond latencies, basically the time it takes to shove something into a channel.

What is your host/environment?

  • OS: Ubuntu 20.02
  • Version: 1.1.0 (but nothing has changed to the bulkindexer since the fork from ES)

Do you have any screenshots?
image

[BUG] User guide example doesn't create index with given mapping

What is the bug?
Example at UserGuide (https://github.com/opensearch-project/opensearch-go/blob/main/USER_GUIDE.md) is incomplete. It does not create an index with specified mapping.

How can one reproduce the bug?
Execute example at https://github.com/opensearch-project/opensearch-go/blob/main/USER_GUIDE.md

What is the expected behavior?
Use this api to create mapping before inserting documents.

What is your host/environment?
N/A

Do you have any screenshots?
N/A

Do you have any additional context?
N/A

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.