From 764877ca0a53904b21c31eed61858e500dee80e9 Mon Sep 17 00:00:00 2001 From: Uros Jovanovic Date: Fri, 3 Apr 2015 21:08:57 +0200 Subject: [PATCH 1/2] * support for windows and centos as "series" --- internal/charmstore/search.go | 17 +++++++++++++---- internal/router/router.go | 26 +++++++++++++++++--------- internal/router/router_test.go | 13 +++++++++++++ 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/internal/charmstore/search.go b/internal/charmstore/search.go index 6a67500ac..5e3235545 100644 --- a/internal/charmstore/search.go +++ b/internal/charmstore/search.go @@ -34,10 +34,18 @@ const typeName = "entity" // reverse order of LTS releases, followed by the latest // non-LTS release, followed by everything else. var seriesBoost = map[string]float64{ - "bundle": 1.1255, - "trusty": 1.125, - "precise": 1.1125, - "utopic": 1.1, + "bundle": 1.1255, + "trusty": 1.125, + "precise": 1.1125, + "utopic": 1.1, + "win2012hvr2": 1.1, + "win2012hv": 1.1, + "win2012r2": 1.1, + "win2012": 1.1, + "win7": 1.1, + "win8": 1.1, + "win81": 1.1, + "centos7": 1.1, } // deprecatedSeries are series that should not show up in search @@ -504,6 +512,7 @@ func queryFields(sp SearchParams) map[string]float64 { "CharmMeta.Categories": 5, "CharmMeta.Tags": 5, "BundleData.Tags": 5, + "Series": 5, "CharmProvidedInterfaces": 3, "CharmRequiredInterfaces": 3, "CharmMeta.Description": 1, diff --git a/internal/router/router.go b/internal/router/router.go index 1e23e5783..146bc0536 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -31,15 +31,23 @@ import ( // code) var knownSeries = map[string]bool{ - "bundle": true, - "oneiric": true, - "precise": true, - "quantal": true, - "raring": true, - "saucy": true, - "trusty": true, - "utopic": true, - "vivid": true, + "bundle": true, + "oneiric": true, + "precise": true, + "quantal": true, + "raring": true, + "saucy": true, + "trusty": true, + "utopic": true, + "vivid": true, + "win2012hvr2": true, + "win2012hv": true, + "win2012r2": true, + "win2012": true, + "win7": true, + "win8": true, + "win81": true, + "centos7": true, } // BulkIncludeHandler represents a metadata handler that can diff --git a/internal/router/router_test.go b/internal/router/router_test.go index 3800c3467..c34a522b6 100644 --- a/internal/router/router_test.go +++ b/internal/router/router_test.go @@ -106,6 +106,19 @@ var routerGetTests = []struct { Method: "GET", CharmURL: "cs:precise/wordpress-34", }, +}, { + about: "windows id handler", + handlers: Handlers{ + Id: map[string]IdHandler{ + "foo": testIdHandler, + }, + }, + urlStr: "/win81/visualstudio-2012/foo", + expectStatus: http.StatusOK, + expectBody: idHandlerTestResp{ + Method: "GET", + CharmURL: "cs:win81/visualstudio-2012", + }, }, { about: "id handler with no series in id", handlers: Handlers{ From 7558903bda9a00b72396f3181db4337f36dbed9e Mon Sep 17 00:00:00 2001 From: Uros Jovanovic Date: Fri, 3 Apr 2015 21:14:41 +0200 Subject: [PATCH 2/2] * todo for better handling of series --- internal/charmstore/search.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/charmstore/search.go b/internal/charmstore/search.go index 5e3235545..03c4d1a6f 100644 --- a/internal/charmstore/search.go +++ b/internal/charmstore/search.go @@ -508,10 +508,13 @@ type SearchResult struct { // elasticsearch query. func queryFields(sp SearchParams) map[string]float64 { fields := map[string]float64{ - "URL.ngrams": 8, - "CharmMeta.Categories": 5, - "CharmMeta.Tags": 5, - "BundleData.Tags": 5, + "URL.ngrams": 8, + "CharmMeta.Categories": 5, + "CharmMeta.Tags": 5, + "BundleData.Tags": 5, + // TODO(uros): Series should be n-grams so that one + // can search for all "win*" charms/bundles even in + // without the series filter. "Series": 5, "CharmProvidedInterfaces": 3, "CharmRequiredInterfaces": 3,