From 88118199b5f1776c83dca08d784532e000865da2 Mon Sep 17 00:00:00 2001 From: Brett Lawson Date: Wed, 15 Jan 2020 02:11:58 -0800 Subject: [PATCH] GOCBC-746: Removed all references to N1QL, CBAS and FTS. Change-Id: I8edb4cd828e46bc4d7d0a4c5a610fd8f7dbc3e28 Reviewed-on: http://review.couchbase.org/120547 Reviewed-by: Brett Lawson Tested-by: Brett Lawson --- cluster.go | 8 +-- cluster_analyticsindexes.go | 22 +++--- cluster_analyticsquery.go | 4 +- cluster_query.go | 6 +- cluster_queryindexes.go | 16 ++--- cluster_searchindexes.go | 26 +++---- cluster_searchindexes_test.go | 12 ++-- cluster_searchquery.go | 2 +- constants.go | 10 +-- query_options.go | 2 +- searchquery.go | 128 +++++++++++++++++----------------- searchquery_facet.go | 16 ++--- searchquery_sorting.go | 44 ++++++------ subdocspecs.go | 2 +- testcluster_test.go | 22 +++--- 15 files changed, 160 insertions(+), 160 deletions(-) diff --git a/cluster.go b/cluster.go index b23f3541..f17b82f5 100644 --- a/cluster.go +++ b/cluster.go @@ -215,10 +215,10 @@ func (c *Cluster) parseExtraConnStrOptions(spec gocbconnstr.ConnSpec) error { return optValue[len(optValue)-1], true } - if valStr, ok := fetchOption("n1ql_timeout"); ok { + if valStr, ok := fetchOption("query_timeout"); ok { val, err := strconv.ParseInt(valStr, 10, 64) if err != nil { - return fmt.Errorf("n1ql_timeout option must be a number") + return fmt.Errorf("query_timeout option must be a number") } c.sb.QueryTimeout = time.Duration(val) * time.Millisecond } @@ -524,7 +524,7 @@ func (c *Cluster) AnalyticsIndexes() *AnalyticsIndexManager { } } -// QueryIndexes returns a QueryIndexManager for managing N1QL indexes. +// QueryIndexes returns a QueryIndexManager for managing query indexes. func (c *Cluster) QueryIndexes() *QueryIndexManager { return &QueryIndexManager{ cluster: c, @@ -532,7 +532,7 @@ func (c *Cluster) QueryIndexes() *QueryIndexManager { } } -// SearchIndexes returns a SearchIndexManager for managing Search indexes. +// SearchIndexes returns a SearchIndexManager for managing search indexes. func (c *Cluster) SearchIndexes() *SearchIndexManager { return &SearchIndexManager{ cluster: c, diff --git a/cluster_analyticsindexes.go b/cluster_analyticsindexes.go index a1533f46..6274dd6d 100644 --- a/cluster_analyticsindexes.go +++ b/cluster_analyticsindexes.go @@ -116,7 +116,7 @@ func (am *AnalyticsIndexManager) CreateDataverse(dataverseName string, opts *Cre } span := am.tracer.StartSpan("CreateDataverse", nil). - SetTag("couchbase.service", "cbas") + SetTag("couchbase.service", "analytics") defer span.Finish() var ignoreStr string @@ -152,7 +152,7 @@ func (am *AnalyticsIndexManager) DropDataverse(dataverseName string, opts *DropA } span := am.tracer.StartSpan("DropDataverse", nil). - SetTag("couchbase.service", "cbas") + SetTag("couchbase.service", "analytics") defer span.Finish() var ignoreStr string @@ -196,7 +196,7 @@ func (am *AnalyticsIndexManager) CreateDataset(datasetName, bucketName string, o } span := am.tracer.StartSpan("CreateDataset", nil). - SetTag("couchbase.service", "cbas") + SetTag("couchbase.service", "analytics") defer span.Finish() var ignoreStr string @@ -247,7 +247,7 @@ func (am *AnalyticsIndexManager) DropDataset(datasetName string, opts *DropAnaly } span := am.tracer.StartSpan("DropDataset", nil). - SetTag("couchbase.service", "cbas") + SetTag("couchbase.service", "analytics") defer span.Finish() var ignoreStr string @@ -287,7 +287,7 @@ func (am *AnalyticsIndexManager) GetAllDatasets(opts *GetAllAnalyticsDatasetsOpt } span := am.tracer.StartSpan("GetAllDatasets", nil). - SetTag("couchbase.service", "cbas") + SetTag("couchbase.service", "analytics") defer span.Finish() q := "SELECT d.* FROM Metadata.`Dataset` d WHERE d.DataverseName <> \"Metadata\"" @@ -344,7 +344,7 @@ func (am *AnalyticsIndexManager) CreateIndex(datasetName, indexName string, fiel } span := am.tracer.StartSpan("CreateIndex", nil). - SetTag("couchbase.service", "cbas") + SetTag("couchbase.service", "analytics") defer span.Finish() var ignoreStr string @@ -392,7 +392,7 @@ func (am *AnalyticsIndexManager) DropIndex(datasetName, indexName string, opts * } span := am.tracer.StartSpan("DropIndex", nil). - SetTag("couchbase.service", "cbas") + SetTag("couchbase.service", "analytics") defer span.Finish() var ignoreStr string @@ -432,7 +432,7 @@ func (am *AnalyticsIndexManager) GetAllIndexes(opts *GetAllAnalyticsIndexesOptio } span := am.tracer.StartSpan("GetAllIndexes", nil). - SetTag("couchbase.service", "cbas") + SetTag("couchbase.service", "analytics") defer span.Finish() q := "SELECT d.* FROM Metadata.`Index` d WHERE d.DataverseName <> \"Metadata\"" @@ -477,7 +477,7 @@ func (am *AnalyticsIndexManager) ConnectLink(opts *ConnectAnalyticsLinkOptions) } span := am.tracer.StartSpan("ConnectLink", nil). - SetTag("couchbase.service", "cbas") + SetTag("couchbase.service", "analytics") defer span.Finish() if opts.LinkName == "" { @@ -512,7 +512,7 @@ func (am *AnalyticsIndexManager) DisconnectLink(opts *DisconnectAnalyticsLinkOpt } span := am.tracer.StartSpan("DisconnectLink", nil). - SetTag("couchbase.service", "cbas") + SetTag("couchbase.service", "analytics") defer span.Finish() if opts.LinkName == "" { @@ -545,7 +545,7 @@ func (am *AnalyticsIndexManager) GetPendingMutations(opts *GetPendingMutationsAn } span := am.tracer.StartSpan("GetPendingMutations", nil). - SetTag("couchbase.service", "cbas") + SetTag("couchbase.service", "analytics") defer span.Finish() req := mgmtRequest{ diff --git a/cluster_analyticsquery.go b/cluster_analyticsquery.go index ae8b2c50..0173659e 100644 --- a/cluster_analyticsquery.go +++ b/cluster_analyticsquery.go @@ -83,7 +83,7 @@ func (warning *AnalyticsWarning) fromData(data jsonAnalyticsWarning) error { return nil } -// AnalyticsMetaData provides access to the meta-data properties of a N1QL query result. +// AnalyticsMetaData provides access to the meta-data properties of a query result. type AnalyticsMetaData struct { RequestID string ClientContextID string @@ -114,7 +114,7 @@ func (meta *AnalyticsMetaData) fromData(data jsonAnalyticsResponse) error { return nil } -// AnalyticsResult allows access to the results of a N1QL query. +// AnalyticsResult allows access to the results of a query. type AnalyticsResult struct { reader *gocbcore.AnalyticsRowReader diff --git a/cluster_query.go b/cluster_query.go index 5983fe28..b0f6c9be 100644 --- a/cluster_query.go +++ b/cluster_query.go @@ -93,7 +93,7 @@ func (warning *QueryWarning) fromData(data jsonQueryWarning) error { return nil } -// QueryMetaData provides access to the meta-data properties of a N1QL query result. +// QueryMetaData provides access to the meta-data properties of a query result. type QueryMetaData struct { RequestID string ClientContextID string @@ -129,7 +129,7 @@ func (meta *QueryMetaData) fromData(data jsonQueryResponse) error { return nil } -// QueryResult allows access to the results of a N1QL query. +// QueryResult allows access to the results of a query. type QueryResult struct { reader *gocbcore.N1QLRowReader @@ -220,7 +220,7 @@ func (r *QueryResult) MetaData() (*QueryMetaData, error) { return &metaData, nil } -// Query executes the N1QL query statement on the server. +// Query executes the query statement on the server. func (c *Cluster) Query(statement string, opts *QueryOptions) (*QueryResult, error) { if opts == nil { opts = &QueryOptions{} diff --git a/cluster_queryindexes.go b/cluster_queryindexes.go index 07d7c9d8..411fab09 100644 --- a/cluster_queryindexes.go +++ b/cluster_queryindexes.go @@ -5,7 +5,7 @@ import ( "time" ) -// QueryIndexManager provides methods for performing Couchbase N1ql index management. +// QueryIndexManager provides methods for performing Couchbase query index management. type QueryIndexManager struct { cluster *Cluster @@ -150,7 +150,7 @@ func (qm *QueryIndexManager) CreateIndex(bucketName, indexName string, fields [] } span := qm.tracer.StartSpan("CreateIndex", nil). - SetTag("couchbase.service", "n1ql") + SetTag("couchbase.service", "query") defer span.Finish() return qm.createIndex(span.Context(), bucketName, indexName, fields, createQueryIndexOptions{ @@ -178,7 +178,7 @@ func (qm *QueryIndexManager) CreatePrimaryIndex(bucketName string, opts *CreateP } span := qm.tracer.StartSpan("CreatePrimaryIndex", nil). - SetTag("couchbase.service", "n1ql") + SetTag("couchbase.service", "query") defer span.Finish() return qm.createIndex( @@ -247,7 +247,7 @@ func (qm *QueryIndexManager) DropIndex(bucketName, indexName string, opts *DropQ } span := qm.tracer.StartSpan("DropIndex", nil). - SetTag("couchbase.service", "n1ql") + SetTag("couchbase.service", "query") defer span.Finish() return qm.dropIndex( @@ -277,7 +277,7 @@ func (qm *QueryIndexManager) DropPrimaryIndex(bucketName string, opts *DropPrima } span := qm.tracer.StartSpan("DropPrimaryIndex", nil). - SetTag("couchbase.service", "n1ql") + SetTag("couchbase.service", "query") defer span.Finish() return qm.dropIndex( @@ -304,7 +304,7 @@ func (qm *QueryIndexManager) GetAllIndexes(bucketName string, opts *GetAllQueryI } span := qm.tracer.StartSpan("GetAllIndexes", nil). - SetTag("couchbase.service", "n1ql") + SetTag("couchbase.service", "query") defer span.Finish() return qm.getAllIndexes(span.Context(), bucketName, opts) @@ -360,7 +360,7 @@ func (qm *QueryIndexManager) BuildDeferredIndexes(bucketName string, opts *Build } span := qm.tracer.StartSpan("BuildDeferredIndexes", nil). - SetTag("couchbase.service", "n1ql") + SetTag("couchbase.service", "query") defer span.Finish() indexList, err := qm.getAllIndexes( @@ -448,7 +448,7 @@ func (qm *QueryIndexManager) WatchIndexes(bucketName string, watchList []string, } span := qm.tracer.StartSpan("WatchIndexes", nil). - SetTag("couchbase.service", "n1ql") + SetTag("couchbase.service", "query") defer span.Finish() if opts.WatchPrimary { diff --git a/cluster_searchindexes.go b/cluster_searchindexes.go index 47f9eded..f9d0de99 100644 --- a/cluster_searchindexes.go +++ b/cluster_searchindexes.go @@ -88,7 +88,7 @@ func (si *SearchIndex) toData() (jsonSearchIndex, error) { return data, nil } -// SearchIndexManager provides methods for performing Couchbase FTS index management. +// SearchIndexManager provides methods for performing Couchbase search index management. type SearchIndexManager struct { cluster *Cluster @@ -118,7 +118,7 @@ func (sm *SearchIndexManager) GetAllIndexes(opts *GetAllSearchIndexOptions) ([]S } span := sm.tracer.StartSpan("GetAllIndexes", nil). - SetTag("couchbase.service", "fts") + SetTag("couchbase.service", "search") defer span.Finish() req := mgmtRequest{ @@ -179,7 +179,7 @@ func (sm *SearchIndexManager) GetIndex(indexName string, opts *GetSearchIndexOpt } span := sm.tracer.StartSpan("GetIndex", nil). - SetTag("couchbase.service", "fts") + SetTag("couchbase.service", "search") defer span.Finish() req := mgmtRequest{ @@ -241,7 +241,7 @@ func (sm *SearchIndexManager) UpsertIndex(indexDefinition SearchIndex, opts *Ups } span := sm.tracer.StartSpan("UpsertIndex", nil). - SetTag("couchbase.service", "fts") + SetTag("couchbase.service", "search") defer span.Finish() indexData, err := indexDefinition.toData() @@ -295,7 +295,7 @@ func (sm *SearchIndexManager) DropIndex(indexName string, opts *DropSearchIndexO } span := sm.tracer.StartSpan("DropIndex", nil). - SetTag("couchbase.service", "fts") + SetTag("couchbase.service", "search") defer span.Finish() req := mgmtRequest{ @@ -335,7 +335,7 @@ func (sm *SearchIndexManager) AnalyzeDocument(indexName string, doc interface{}, } span := sm.tracer.StartSpan("AnalyzeDocument", nil). - SetTag("couchbase.service", "fts") + SetTag("couchbase.service", "search") defer span.Finish() b, err := json.Marshal(doc) @@ -397,7 +397,7 @@ func (sm *SearchIndexManager) GetIndexedDocumentsCount(indexName string, opts *G } span := sm.tracer.StartSpan("GetIndexedDocumentsCount", nil). - SetTag("couchbase.service", "fts") + SetTag("couchbase.service", "search") defer span.Finish() req := mgmtRequest{ @@ -478,7 +478,7 @@ func (sm *SearchIndexManager) PauseIngest(indexName string, opts *PauseIngestSea } span := sm.tracer.StartSpan("PauseIngest", nil). - SetTag("couchbase.service", "fts") + SetTag("couchbase.service", "search") defer span.Finish() return sm.performControlRequest( @@ -507,7 +507,7 @@ func (sm *SearchIndexManager) ResumeIngest(indexName string, opts *ResumeIngestS } span := sm.tracer.StartSpan("ResumeIngest", nil). - SetTag("couchbase.service", "fts") + SetTag("couchbase.service", "search") defer span.Finish() return sm.performControlRequest( @@ -536,7 +536,7 @@ func (sm *SearchIndexManager) AllowQuerying(indexName string, opts *AllowQueryin } span := sm.tracer.StartSpan("AllowQuerying", nil). - SetTag("couchbase.service", "fts") + SetTag("couchbase.service", "search") defer span.Finish() return sm.performControlRequest( @@ -565,7 +565,7 @@ func (sm *SearchIndexManager) DisallowQuerying(indexName string, opts *AllowQuer } span := sm.tracer.StartSpan("DisallowQuerying", nil). - SetTag("couchbase.service", "fts") + SetTag("couchbase.service", "search") defer span.Finish() return sm.performControlRequest( @@ -594,7 +594,7 @@ func (sm *SearchIndexManager) FreezePlan(indexName string, opts *AllowQueryingSe } span := sm.tracer.StartSpan("FreezePlan", nil). - SetTag("couchbase.service", "fts") + SetTag("couchbase.service", "search") defer span.Finish() return sm.performControlRequest( @@ -623,7 +623,7 @@ func (sm *SearchIndexManager) UnfreezePlan(indexName string, opts *AllowQuerying } span := sm.tracer.StartSpan("UnfreezePlan", nil). - SetTag("couchbase.service", "fts") + SetTag("couchbase.service", "search") defer span.Finish() return sm.performControlRequest( diff --git a/cluster_searchindexes_test.go b/cluster_searchindexes_test.go index a5c85d18..acad4e22 100644 --- a/cluster_searchindexes_test.go +++ b/cluster_searchindexes_test.go @@ -6,7 +6,7 @@ import ( ) func TestSearchIndexesCrud(t *testing.T) { - if !globalCluster.SupportsFeature(FtsIndexFeature) { + if !globalCluster.SupportsFeature(SearchIndexFeature) { t.Skip("Skipping test as search indexes not supported") } @@ -83,7 +83,7 @@ func TestSearchIndexesCrud(t *testing.T) { t.Fatalf("Expected GetAll to return more than 0 indexes") } - if globalCluster.SupportsFeature(FtsAnalyzeFeature) { + if globalCluster.SupportsFeature(SearchAnalyzeFeature) { analysis, err := mgr.AnalyzeDocument("test", struct { Field1 string Field2 string @@ -137,7 +137,7 @@ func TestSearchIndexesCrud(t *testing.T) { } func TestSearchIndexesUpsertIndexNoName(t *testing.T) { - if !globalCluster.SupportsFeature(FtsIndexFeature) { + if !globalCluster.SupportsFeature(SearchIndexFeature) { t.Skip("Skipping test as search indexes not supported") } @@ -154,7 +154,7 @@ func TestSearchIndexesUpsertIndexNoName(t *testing.T) { } func TestSearchIndexesIngestControl(t *testing.T) { - if !globalCluster.SupportsFeature(FtsIndexFeature) { + if !globalCluster.SupportsFeature(SearchIndexFeature) { t.Skip("Skipping test as search indexes not supported") } @@ -184,7 +184,7 @@ func TestSearchIndexesIngestControl(t *testing.T) { } func TestSearchIndexesQueryControl(t *testing.T) { - if !globalCluster.SupportsFeature(FtsIndexFeature) { + if !globalCluster.SupportsFeature(SearchIndexFeature) { t.Skip("Skipping test as search indexes not supported") } @@ -214,7 +214,7 @@ func TestSearchIndexesQueryControl(t *testing.T) { } func TestSearchIndexesPartitionControl(t *testing.T) { - if !globalCluster.SupportsFeature(FtsIndexFeature) { + if !globalCluster.SupportsFeature(SearchIndexFeature) { t.Skip("Skipping test as search indexes not supported") } diff --git a/cluster_searchquery.go b/cluster_searchquery.go index 6ac79399..c5bdbd96 100644 --- a/cluster_searchquery.go +++ b/cluster_searchquery.go @@ -132,7 +132,7 @@ func (sr *SearchRow) Fields(valuePtr interface{}) error { return json.Unmarshal(sr.fieldsBytes, valuePtr) } -// SearchResult allows access to the results of a N1QL query. +// SearchResult allows access to the results of a search query. type SearchResult struct { reader *gocbcore.SearchRowReader diff --git a/constants.go b/constants.go index 2cc70c7b..683a32c9 100644 --- a/constants.go +++ b/constants.go @@ -12,8 +12,8 @@ const ( type QueryIndexType string const ( - // QueryIndexTypeN1ql indicates that GSI was used to build the index. - QueryIndexTypeN1ql = QueryIndexType("gsi") + // QueryIndexTypeGsi indicates that GSI was used to build the index. + QueryIndexTypeGsi = QueryIndexType("gsi") // QueryIndexTypeView indicates that views were used to build the index. QueryIndexTypeView = QueryIndexType("views") @@ -58,16 +58,16 @@ const ( type ServiceType gocbcore.ServiceType const ( - // ServiceTypeManagement represents a management service (typically ns_server). + // ServiceTypeManagement represents a management service. ServiceTypeManagement = ServiceType(gocbcore.MgmtService) // ServiceTypeKeyValue represents a memcached service. ServiceTypeKeyValue = ServiceType(gocbcore.MemdService) - // ServiceTypeViews represents a CouchAPI service (typically for views). + // ServiceTypeViews represents a views service. ServiceTypeViews = ServiceType(gocbcore.CapiService) - // ServiceTypeQuery represents a N1QL service (typically for query). + // ServiceTypeQuery represents a query service. ServiceTypeQuery = ServiceType(gocbcore.N1qlService) // ServiceTypeSearch represents a full-text-search service. diff --git a/query_options.go b/query_options.go index c0c77d59..b25c47b2 100644 --- a/query_options.go +++ b/query_options.go @@ -18,7 +18,7 @@ const ( QueryScanConsistencyRequestPlus = QueryScanConsistency(2) ) -// QueryOptions represents the options available when executing a N1QL query. +// QueryOptions represents the options available when executing a query. type QueryOptions struct { ScanConsistency QueryScanConsistency ConsistentWith *MutationState diff --git a/searchquery.go b/searchquery.go index f60f2e63..e85106ba 100644 --- a/searchquery.go +++ b/searchquery.go @@ -6,29 +6,29 @@ import "encoding/json" type SearchQuery interface { } -type ftsQueryBase struct { +type searchQueryBase struct { options map[string]interface{} } -func newFtsQueryBase() ftsQueryBase { - return ftsQueryBase{ +func newSearchQueryBase() searchQueryBase { + return searchQueryBase{ options: make(map[string]interface{}), } } -// MarshalJSON marshal's this query to JSON for the FTS REST API. -func (q ftsQueryBase) MarshalJSON() ([]byte, error) { +// MarshalJSON marshal's this query to JSON for the search REST API. +func (q searchQueryBase) MarshalJSON() ([]byte, error) { return json.Marshal(q.options) } -// MatchQuery represents a FTS match query. +// MatchQuery represents a search match query. type MatchQuery struct { - ftsQueryBase + searchQueryBase } // NewMatchQuery creates a new MatchQuery. func NewMatchQuery(match string) *MatchQuery { - q := &MatchQuery{newFtsQueryBase()} + q := &MatchQuery{newSearchQueryBase()} q.options["match"] = match return q } @@ -63,14 +63,14 @@ func (q *MatchQuery) Boost(boost float32) *MatchQuery { return q } -// MatchPhraseQuery represents a FTS match phrase query. +// MatchPhraseQuery represents a search match phrase query. type MatchPhraseQuery struct { - ftsQueryBase + searchQueryBase } // NewMatchPhraseQuery creates a new MatchPhraseQuery func NewMatchPhraseQuery(phrase string) *MatchPhraseQuery { - q := &MatchPhraseQuery{newFtsQueryBase()} + q := &MatchPhraseQuery{newSearchQueryBase()} q.options["match_phrase"] = phrase return q } @@ -93,14 +93,14 @@ func (q *MatchPhraseQuery) Boost(boost float32) *MatchPhraseQuery { return q } -// RegexpQuery represents a FTS regular expression query. +// RegexpQuery represents a search regular expression query. type RegexpQuery struct { - ftsQueryBase + searchQueryBase } // NewRegexpQuery creates a new RegexpQuery. func NewRegexpQuery(regexp string) *RegexpQuery { - q := &RegexpQuery{newFtsQueryBase()} + q := &RegexpQuery{newSearchQueryBase()} q.options["regexp"] = regexp return q } @@ -117,14 +117,14 @@ func (q *RegexpQuery) Boost(boost float32) *RegexpQuery { return q } -// QueryStringQuery represents a FTS string query. +// QueryStringQuery represents a search string query. type QueryStringQuery struct { - ftsQueryBase + searchQueryBase } // NewQueryStringQuery creates a new StringQuery. func NewQueryStringQuery(query string) *QueryStringQuery { - q := &QueryStringQuery{newFtsQueryBase()} + q := &QueryStringQuery{newSearchQueryBase()} q.options["query"] = query return q } @@ -135,14 +135,14 @@ func (q *QueryStringQuery) Boost(boost float32) *QueryStringQuery { return q } -// NumericRangeQuery represents a FTS numeric range query. +// NumericRangeQuery represents a search numeric range query. type NumericRangeQuery struct { - ftsQueryBase + searchQueryBase } // NewNumericRangeQuery creates a new NumericRangeQuery. func NewNumericRangeQuery() *NumericRangeQuery { - q := &NumericRangeQuery{newFtsQueryBase()} + q := &NumericRangeQuery{newSearchQueryBase()} return q } @@ -172,14 +172,14 @@ func (q *NumericRangeQuery) Boost(boost float32) *NumericRangeQuery { return q } -// DateRangeQuery represents a FTS date range query. +// DateRangeQuery represents a search date range query. type DateRangeQuery struct { - ftsQueryBase + searchQueryBase } // NewDateRangeQuery creates a new DateRangeQuery. func NewDateRangeQuery() *DateRangeQuery { - q := &DateRangeQuery{newFtsQueryBase()} + q := &DateRangeQuery{newSearchQueryBase()} return q } @@ -215,14 +215,14 @@ func (q *DateRangeQuery) Boost(boost float32) *DateRangeQuery { return q } -// ConjunctionQuery represents a FTS conjunction query. +// ConjunctionQuery represents a search conjunction query. type ConjunctionQuery struct { - ftsQueryBase + searchQueryBase } // NewConjunctionQuery creates a new ConjunctionQuery. func NewConjunctionQuery(queries ...SearchQuery) *ConjunctionQuery { - q := &ConjunctionQuery{newFtsQueryBase()} + q := &ConjunctionQuery{newSearchQueryBase()} q.options["conjuncts"] = []SearchQuery{} return q.And(queries...) } @@ -239,14 +239,14 @@ func (q *ConjunctionQuery) Boost(boost float32) *ConjunctionQuery { return q } -// DisjunctionQuery represents a FTS disjunction query. +// DisjunctionQuery represents a search disjunction query. type DisjunctionQuery struct { - ftsQueryBase + searchQueryBase } // NewDisjunctionQuery creates a new DisjunctionQuery. func NewDisjunctionQuery(queries ...SearchQuery) *DisjunctionQuery { - q := &DisjunctionQuery{newFtsQueryBase()} + q := &DisjunctionQuery{newSearchQueryBase()} q.options["disjuncts"] = []SearchQuery{} return q.Or(queries...) } @@ -270,7 +270,7 @@ type booleanQueryData struct { Boost float32 `json:"boost,omitempty"` } -// BooleanQuery represents a FTS boolean query. +// BooleanQuery represents a search boolean query. type BooleanQuery struct { data booleanQueryData shouldMin int @@ -333,7 +333,7 @@ func (q *BooleanQuery) Boost(boost float32) *BooleanQuery { return q } -// MarshalJSON marshal's this query to JSON for the FTS REST API. +// MarshalJSON marshal's this query to JSON for the search REST API. func (q *BooleanQuery) MarshalJSON() ([]byte, error) { if q.data.Should != nil { q.data.Should.options["min"] = q.shouldMin @@ -345,14 +345,14 @@ func (q *BooleanQuery) MarshalJSON() ([]byte, error) { return bytes, err } -// WildcardQuery represents a FTS wildcard query. +// WildcardQuery represents a search wildcard query. type WildcardQuery struct { - ftsQueryBase + searchQueryBase } // NewWildcardQuery creates a new WildcardQuery. func NewWildcardQuery(wildcard string) *WildcardQuery { - q := &WildcardQuery{newFtsQueryBase()} + q := &WildcardQuery{newSearchQueryBase()} q.options["wildcard"] = wildcard return q } @@ -369,14 +369,14 @@ func (q *WildcardQuery) Boost(boost float32) *WildcardQuery { return q } -// DocIDQuery represents a FTS document id query. +// DocIDQuery represents a search document id query. type DocIDQuery struct { - ftsQueryBase + searchQueryBase } // NewDocIDQuery creates a new DocIdQuery. func NewDocIDQuery(ids ...string) *DocIDQuery { - q := &DocIDQuery{newFtsQueryBase()} + q := &DocIDQuery{newSearchQueryBase()} q.options["ids"] = []string{} return q.AddDocIds(ids...) } @@ -399,14 +399,14 @@ func (q *DocIDQuery) Boost(boost float32) *DocIDQuery { return q } -// BooleanFieldQuery represents a FTS boolean field query. +// BooleanFieldQuery represents a search boolean field query. type BooleanFieldQuery struct { - ftsQueryBase + searchQueryBase } // NewBooleanFieldQuery creates a new BooleanFieldQuery. func NewBooleanFieldQuery(val bool) *BooleanFieldQuery { - q := &BooleanFieldQuery{newFtsQueryBase()} + q := &BooleanFieldQuery{newSearchQueryBase()} q.options["bool"] = val return q } @@ -423,14 +423,14 @@ func (q *BooleanFieldQuery) Boost(boost float32) *BooleanFieldQuery { return q } -// TermQuery represents a FTS term query. +// TermQuery represents a search term query. type TermQuery struct { - ftsQueryBase + searchQueryBase } // NewTermQuery creates a new TermQuery. func NewTermQuery(term string) *TermQuery { - q := &TermQuery{newFtsQueryBase()} + q := &TermQuery{newSearchQueryBase()} q.options["term"] = term return q } @@ -459,14 +459,14 @@ func (q *TermQuery) Boost(boost float32) *TermQuery { return q } -// PhraseQuery represents a FTS phrase query. +// PhraseQuery represents a search phrase query. type PhraseQuery struct { - ftsQueryBase + searchQueryBase } // NewPhraseQuery creates a new PhraseQuery. func NewPhraseQuery(terms ...string) *PhraseQuery { - q := &PhraseQuery{newFtsQueryBase()} + q := &PhraseQuery{newSearchQueryBase()} q.options["terms"] = terms return q } @@ -483,14 +483,14 @@ func (q *PhraseQuery) Boost(boost float32) *PhraseQuery { return q } -// PrefixQuery represents a FTS prefix query. +// PrefixQuery represents a search prefix query. type PrefixQuery struct { - ftsQueryBase + searchQueryBase } // NewPrefixQuery creates a new PrefixQuery. func NewPrefixQuery(prefix string) *PrefixQuery { - q := &PrefixQuery{newFtsQueryBase()} + q := &PrefixQuery{newSearchQueryBase()} q.options["prefix"] = prefix return q } @@ -507,38 +507,38 @@ func (q *PrefixQuery) Boost(boost float32) *PrefixQuery { return q } -// MatchAllQuery represents a FTS match all query. +// MatchAllQuery represents a search match all query. type MatchAllQuery struct { - ftsQueryBase + searchQueryBase } // NewMatchAllQuery creates a new MatchAllQuery. func NewMatchAllQuery() *MatchAllQuery { - q := &MatchAllQuery{newFtsQueryBase()} + q := &MatchAllQuery{newSearchQueryBase()} q.options["match_all"] = nil return q } -// MatchNoneQuery represents a FTS match none query. +// MatchNoneQuery represents a search match none query. type MatchNoneQuery struct { - ftsQueryBase + searchQueryBase } // NewMatchNoneQuery creates a new MatchNoneQuery. func NewMatchNoneQuery() *MatchNoneQuery { - q := &MatchNoneQuery{newFtsQueryBase()} + q := &MatchNoneQuery{newSearchQueryBase()} q.options["match_none"] = nil return q } -// TermRangeQuery represents a FTS term range query. +// TermRangeQuery represents a search term range query. type TermRangeQuery struct { - ftsQueryBase + searchQueryBase } // NewTermRangeQuery creates a new TermRangeQuery. func NewTermRangeQuery(term string) *TermRangeQuery { - q := &TermRangeQuery{newFtsQueryBase()} + q := &TermRangeQuery{newSearchQueryBase()} q.options["term"] = term return q } @@ -569,14 +569,14 @@ func (q *TermRangeQuery) Boost(boost float32) *TermRangeQuery { return q } -// GeoDistanceQuery represents a FTS geographical distance query. +// GeoDistanceQuery represents a search geographical distance query. type GeoDistanceQuery struct { - ftsQueryBase + searchQueryBase } // NewGeoDistanceQuery creates a new GeoDistanceQuery. func NewGeoDistanceQuery(lon, lat float64, distance string) *GeoDistanceQuery { - q := &GeoDistanceQuery{newFtsQueryBase()} + q := &GeoDistanceQuery{newSearchQueryBase()} q.options["location"] = []float64{lon, lat} q.options["distance"] = distance return q @@ -594,14 +594,14 @@ func (q *GeoDistanceQuery) Boost(boost float32) *GeoDistanceQuery { return q } -// GeoBoundingBoxQuery represents a FTS geographical bounding box query. +// GeoBoundingBoxQuery represents a search geographical bounding box query. type GeoBoundingBoxQuery struct { - ftsQueryBase + searchQueryBase } // NewGeoBoundingBoxQuery creates a new GeoBoundingBoxQuery. func NewGeoBoundingBoxQuery(tlLon, tlLat, brLon, brLat float64) *GeoBoundingBoxQuery { - q := &GeoBoundingBoxQuery{newFtsQueryBase()} + q := &GeoBoundingBoxQuery{newSearchQueryBase()} q.options["top_left"] = []float64{tlLon, tlLat} q.options["bottom_right"] = []float64{brLon, brLat} return q diff --git a/searchquery_facet.go b/searchquery_facet.go index 39d8b87f..9b50ac0b 100644 --- a/searchquery_facet.go +++ b/searchquery_facet.go @@ -4,8 +4,8 @@ import ( "encoding/json" ) -// FtsFacet represents a facet for a search query. -type FtsFacet interface { +// SearchFacet represents a facet for a search query. +type SearchFacet interface { } type termFacetData struct { @@ -13,12 +13,12 @@ type termFacetData struct { Size int `json:"size,omitempty"` } -// TermFacet is an FTS term facet. +// TermFacet is an search term facet. type TermFacet struct { data termFacetData } -// MarshalJSON marshal's this facet to JSON for the FTS REST API. +// MarshalJSON marshal's this facet to JSON for the search REST API. func (f TermFacet) MarshalJSON() ([]byte, error) { return json.Marshal(f.data) } @@ -42,12 +42,12 @@ type numericFacetData struct { NumericRanges []numericFacetRange `json:"numeric_ranges,omitempty"` } -// NumericFacet is an FTS numeric range facet. +// NumericFacet is an search numeric range facet. type NumericFacet struct { data numericFacetData } -// MarshalJSON marshal's this facet to JSON for the FTS REST API. +// MarshalJSON marshal's this facet to JSON for the search REST API. func (f NumericFacet) MarshalJSON() ([]byte, error) { return json.Marshal(f.data) } @@ -81,12 +81,12 @@ type dateFacetData struct { DateRanges []dateFacetRange `json:"date_ranges,omitempty"` } -// DateFacet is an FTS date range facet. +// DateFacet is an search date range facet. type DateFacet struct { data dateFacetData } -// MarshalJSON marshal's this facet to JSON for the FTS REST API. +// MarshalJSON marshal's this facet to JSON for the search REST API. func (f DateFacet) MarshalJSON() ([]byte, error) { return json.Marshal(f.data) } diff --git a/searchquery_sorting.go b/searchquery_sorting.go index becad86c..5e0e703d 100644 --- a/searchquery_sorting.go +++ b/searchquery_sorting.go @@ -4,33 +4,33 @@ import ( "encoding/json" ) -// FtsSort represents an FTS sorting for a search query. -type FtsSort interface { +// SearchSort represents an search sorting for a search query. +type SearchSort interface { } -type ftsSortBase struct { +type searchSortBase struct { options map[string]interface{} } -func newFtsSortBase() ftsSortBase { - return ftsSortBase{ +func newSearchSortBase() searchSortBase { + return searchSortBase{ options: make(map[string]interface{}), } } -// MarshalJSON marshal's this query to JSON for the FTS REST API. -func (q ftsSortBase) MarshalJSON() ([]byte, error) { +// MarshalJSON marshal's this query to JSON for the search REST API. +func (q searchSortBase) MarshalJSON() ([]byte, error) { return json.Marshal(q.options) } -// SearchSortScore represents a FTS score sort. +// SearchSortScore represents a search score sort. type SearchSortScore struct { - ftsSortBase + searchSortBase } // NewSearchSortScore creates a new SearchSortScore. func NewSearchSortScore() *SearchSortScore { - q := &SearchSortScore{newFtsSortBase()} + q := &SearchSortScore{newSearchSortBase()} q.options["by"] = "score" return q } @@ -41,14 +41,14 @@ func (q *SearchSortScore) Descending(descending bool) *SearchSortScore { return q } -// SearchSortID represents a FTS Document ID sort. +// SearchSortID represents a search Document ID sort. type SearchSortID struct { - ftsSortBase + searchSortBase } // NewSearchSortID creates a new SearchSortScore. func NewSearchSortID() *SearchSortID { - q := &SearchSortID{newFtsSortBase()} + q := &SearchSortID{newSearchSortBase()} q.options["by"] = "id" return q } @@ -59,32 +59,32 @@ func (q *SearchSortID) Descending(descending bool) *SearchSortID { return q } -// SearchSortField represents a FTS field sort. +// SearchSortField represents a search field sort. type SearchSortField struct { - ftsSortBase + searchSortBase } // NewSearchSortField creates a new SearchSortField. func NewSearchSortField(field string) *SearchSortField { - q := &SearchSortField{newFtsSortBase()} + q := &SearchSortField{newSearchSortBase()} q.options["by"] = "field" q.options["field"] = field return q } -// Type allows you to specify the FTS field sort type. +// Type allows you to specify the search field sort type. func (q *SearchSortField) Type(value string) *SearchSortField { q.options["type"] = value return q } -// Mode allows you to specify the FTS field sort mode. +// Mode allows you to specify the search field sort mode. func (q *SearchSortField) Mode(mode string) *SearchSortField { q.options["mode"] = mode return q } -// Missing allows you to specify the FTS field sort missing behaviour. +// Missing allows you to specify the search field sort missing behaviour. func (q *SearchSortField) Missing(missing string) *SearchSortField { q.options["missing"] = missing return q @@ -96,14 +96,14 @@ func (q *SearchSortField) Descending(descending bool) *SearchSortField { return q } -// SearchSortGeoDistance represents a FTS geo sort. +// SearchSortGeoDistance represents a search geo sort. type SearchSortGeoDistance struct { - ftsSortBase + searchSortBase } // NewSearchSortGeoDistance creates a new SearchSortGeoDistance. func NewSearchSortGeoDistance(field string, lon, lat float64) *SearchSortGeoDistance { - q := &SearchSortGeoDistance{newFtsSortBase()} + q := &SearchSortGeoDistance{newSearchSortBase()} q.options["by"] = "geo_distance" q.options["field"] = field q.options["location"] = []float64{lon, lat} diff --git a/subdocspecs.go b/subdocspecs.go index 78589dd5..cc816c34 100644 --- a/subdocspecs.go +++ b/subdocspecs.go @@ -26,7 +26,7 @@ type GetSpecOptions struct { // GetSpec indicates a path to be retrieved from the document. The value of the path // can later be retrieved from the LookupResult. -// The path syntax follows N1QL's path syntax (e.g. `foo.bar.baz`). +// The path syntax follows query's path syntax (e.g. `foo.bar.baz`). func GetSpec(path string, opts *GetSpecOptions) LookupInSpec { if opts == nil { opts = &GetSpecOptions{} diff --git a/testcluster_test.go b/testcluster_test.go index b9fbcc6d..aecf2e92 100644 --- a/testcluster_test.go +++ b/testcluster_test.go @@ -36,13 +36,13 @@ var ( SslFeature = FeatureCode(4) DcpFeature = FeatureCode(5) SpatialViewFeature = FeatureCode(6) - N1qlFeature = FeatureCode(7) + QueryFeature = FeatureCode(7) SubdocFeature = FeatureCode(8) KvErrorMapFeature = FeatureCode(9) RbacFeature = FeatureCode(10) - FtsFeature = FeatureCode(11) + SearchFeature = FeatureCode(11) EnhancedErrorsFeature = FeatureCode(12) - FtsIndexFeature = FeatureCode(13) + SearchIndexFeature = FeatureCode(13) CompressionFeature = FeatureCode(14) ServerSideTracingFeature = FeatureCode(15) AnalyticsFeature = FeatureCode(16) @@ -56,7 +56,7 @@ var ( UserManagerFeature = FeatureCode(24) AnalyticsIndexFeature = FeatureCode(25) BucketMgrFeature = FeatureCode(26) - FtsAnalyzeFeature = FeatureCode(27) + SearchAnalyzeFeature = FeatureCode(27) AnalyticsIndexPendingMutationsFeature = FeatureCode(28) GetMetaFeature = FeatureCode(29) ) @@ -92,7 +92,7 @@ func (c *testCluster) SupportsFeature(feature FeatureCode) bool { switch feature { case RbacFeature: supported = !c.Version.Lower(mockVer156) - case FtsIndexFeature: + case SearchIndexFeature: supported = false case CompressionFeature: supported = !c.Version.Lower(mockVer1513) @@ -100,7 +100,7 @@ func (c *testCluster) SupportsFeature(feature FeatureCode) bool { supported = !c.Version.Lower(mockVer1515) case AnalyticsFeature: supported = false - case N1qlFeature: + case QueryFeature: supported = false case XattrFeature: supported = false @@ -120,7 +120,7 @@ func (c *testCluster) SupportsFeature(feature FeatureCode) bool { supported = false case BucketMgrFeature: supported = false - case FtsAnalyzeFeature: + case SearchAnalyzeFeature: supported = false case AnalyticsIndexPendingMutationsFeature: supported = false @@ -141,7 +141,7 @@ func (c *testCluster) SupportsFeature(feature FeatureCode) bool { supported = !c.Version.Lower(srvVer400) case SpatialViewFeature: supported = !c.Version.Lower(srvVer400) - case N1qlFeature: + case QueryFeature: supported = !c.Version.Lower(srvVer400) case SubdocFeature: supported = !c.Version.Lower(srvVer450) @@ -151,11 +151,11 @@ func (c *testCluster) SupportsFeature(feature FeatureCode) bool { supported = !c.Version.Lower(srvVer500) case RbacFeature: supported = !c.Version.Lower(srvVer500) - case FtsFeature: + case SearchFeature: supported = !c.Version.Lower(srvVer500) case EnhancedErrorsFeature: supported = !c.Version.Lower(srvVer500) - case FtsIndexFeature: + case SearchIndexFeature: supported = !c.Version.Lower(srvVer500) case CompressionFeature: supported = !c.Version.Lower(srvVer550) @@ -181,7 +181,7 @@ func (c *testCluster) SupportsFeature(feature FeatureCode) bool { supported = !c.Version.Lower(srvVer600) case BucketMgrFeature: supported = true - case FtsAnalyzeFeature: + case SearchAnalyzeFeature: supported = !c.Version.Lower(srvVer650) case AnalyticsIndexPendingMutationsFeature: supported = !c.Version.Lower(srvVer650)