Skip to content

Commit

Permalink
INTMDB-17: Update search (#223)
Browse files Browse the repository at this point in the history
* change search index struct

* change test

* fix search test

Co-authored-by: Abner Garcia <abner.garcia@edgelab.mx>
  • Loading branch information
abner-dou and Abner Garcia committed Jun 23, 2021
1 parent 75b0d6e commit b374654
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
19 changes: 11 additions & 8 deletions mongodbatlas/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,15 @@ func (s *SearchServiceOp) UpdateAllAnalyzers(ctx context.Context, groupID, clust

// SearchIndex index definition.
type SearchIndex struct {
Analyzer string `json:"analyzer,omitempty"`
CollectionName string `json:"collectionName"`
Database string `json:"database"`
IndexID string `json:"indexID,omitempty"`
Mappings *IndexMapping `json:"mappings,omitempty"`
Name string `json:"name"`
SearchAnalyzer string `json:"searchAnalyzer,omitempty"`
Analyzer string `json:"analyzer,omitempty"`
Analyzers map[string]interface{} `json:"analyzers,omitempty"` // Custom analyzers
CollectionName string `json:"collectionName"`
Database string `json:"database"`
IndexID string `json:"indexID,omitempty"`
Mappings *IndexMapping `json:"mappings,omitempty"`
Name string `json:"name"`
SearchAnalyzer string `json:"searchAnalyzer,omitempty"`
Status string `json:"status,omitempty"`
}

// IndexMapping containing index specifications for the collection fields.
Expand Down Expand Up @@ -281,7 +283,8 @@ type IndexField struct {
// SearchAnalyzer custom analyzer definition.
type SearchAnalyzer struct {
BaseAnalyzer string `json:"baseAnalyzer"`
MaxTokenLength *float64 `json:"maxTokenLength,omitempty"`
MaxTokenLength *int `json:"maxTokenLength,omitempty"`
IgnoreCase *bool `json:"ignoreCase,omitempty"`
Name string `json:"name"`
StemExclusionSet []string `json:"stemExclusionSet,omitempty"`
Stopwords []string `json:"stopwords,omitempty"`
Expand Down
11 changes: 7 additions & 4 deletions mongodbatlas/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func TestSearch_ListAnalyzers(t *testing.T) {
expected := []*SearchAnalyzer{
{
BaseAnalyzer: "lucene.standard",
MaxTokenLength: pointy.Float64(32),
MaxTokenLength: pointy.Int(32),
Name: "my_new_analyzer",
},
{
Expand All @@ -377,7 +377,8 @@ func TestSearch_UpdateAllAnalyzers(t *testing.T) {
{
"baseAnalyzer" : "lucene.standard",
"maxTokenLength" : 32,
"name" : "my_new_analyzer"
"name" : "my_new_analyzer",
"ignoreCase": true
},
{
"baseAnalyzer" : "lucene.english",
Expand All @@ -390,8 +391,9 @@ func TestSearch_UpdateAllAnalyzers(t *testing.T) {
request := []*SearchAnalyzer{
{
BaseAnalyzer: "lucene.standard",
MaxTokenLength: pointy.Float64(32),
MaxTokenLength: pointy.Int(32),
Name: "my_new_analyzer",
IgnoreCase: pointy.Bool(true),
},
{
BaseAnalyzer: "lucene.english",
Expand All @@ -408,8 +410,9 @@ func TestSearch_UpdateAllAnalyzers(t *testing.T) {
expected := []*SearchAnalyzer{
{
BaseAnalyzer: "lucene.standard",
MaxTokenLength: pointy.Float64(32),
MaxTokenLength: pointy.Int(32),
Name: "my_new_analyzer",
IgnoreCase: pointy.Bool(true),
},
{
BaseAnalyzer: "lucene.english",
Expand Down

0 comments on commit b374654

Please sign in to comment.