aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2018-01-16 23:10:40 -0500
committerAlec Warner <antarus@gentoo.org>2018-01-16 23:10:40 -0500
commitc0dea2c99c7bd5b6edd0ff751822dc75a377c3cf (patch)
treef4c01c9e2f7f9ee72c408966d70c31ac15c5dc20 /app
parentFix typo that broke compilation. (diff)
downloadpackages-c0dea2c99c7bd5b6edd0ff751822dc75a377c3cf.tar.gz
packages-c0dea2c99c7bd5b6edd0ff751822dc75a377c3cf.tar.bz2
packages-c0dea2c99c7bd5b6edd0ff751822dc75a377c3cf.zip
Update ES indexing scheme for ES6.
ES6 introduces a number of breaking changes into ES. 1) https://www.elastic.co/guide/en/elasticsearch/reference/master/removal-of-types.html This basically entails breaking up the single multi-typel index we had into N indices, one per model. Our other option is to continue to use a single index, but add a custom type property. This seemed unwieldy. 2) The 'String' type was also deprecated. See https://www.elastic.co/blog/strings-are-dead-long-live-strings So we see many updates from "not analyzed" to "keyword" to retain the previous behavior
Diffstat (limited to 'app')
-rw-r--r--app/models/category.rb8
-rw-r--r--app/models/change.rb12
-rw-r--r--app/models/package.rb26
-rw-r--r--app/models/useflag.rb12
-rw-r--r--app/models/version.rb28
5 files changed, 45 insertions, 41 deletions
diff --git a/app/models/category.rb b/app/models/category.rb
index 5fa31ea..d00c88f 100644
--- a/app/models/category.rb
+++ b/app/models/category.rb
@@ -2,11 +2,11 @@ class Category
include Elasticsearch::Persistence::Model
include Kkuleomi::Store::Model
- index_name "packages-#{Rails.env}"
+ index_name "categories-#{Rails.env}"
- attribute :name, String, mapping: { index: 'not_analyzed' }
- attribute :description, String
- attribute :metadata_hash, String, mapping: { index: 'not_analyzed' }
+ attribute :name, String, mapping: { type: 'text' }
+ attribute :description, String, mapping: { type: 'text' }
+ attribute :metadata_hash, String, mapping: { type: 'text' }
# Determines if the document model needs an update from the repository model
#
diff --git a/app/models/change.rb b/app/models/change.rb
index 9ffe258..9ad8e70 100644
--- a/app/models/change.rb
+++ b/app/models/change.rb
@@ -2,12 +2,12 @@ class Change
include Elasticsearch::Persistence::Model
include Kkuleomi::Store::Model
- index_name "packages-#{Rails.env}"
+ index_name "changes-#{Rails.env}"
- attribute :package, String, mapping: { index: 'not_analyzed' }
- attribute :category, String, mapping: { index: 'not_analyzed' }
- attribute :change_type, String, mapping: { index: 'not_analyzed' }
- attribute :version, String, mapping: { index: 'not_analyzed' }
- attribute :arches, String, mapping: { index: 'not_analyzed' }
+ attribute :package, String, mapping: { type: 'text' }
+ attribute :category, String, mapping: { type: 'text' }
+ attribute :change_type, String, mapping: { type: 'text' }
+ attribute :version, String, mapping: { type: 'text' }
+ attribute :arches, String, mapping: { type: 'text' }
attribute :commit, Hash, default: {}, mapping: { type: 'object' }
end
diff --git a/app/models/package.rb b/app/models/package.rb
index 24cbd8b..1f98e04 100644
--- a/app/models/package.rb
+++ b/app/models/package.rb
@@ -6,19 +6,23 @@ class Package
index_name "packages-#{Rails.env}"
- attribute :category, String, mapping: { index: 'not_analyzed' }
- attribute :name, String, mapping: { index: 'not_analyzed' }
- attribute :name_sort, String, mapping: { index: 'not_analyzed' }
- attribute :atom, String, mapping: { index: 'not_analyzed' }
- attribute :description, String
- attribute :longdescription, String
- attribute :homepage, String, default: [], mapping: { index: 'not_analyzed' }
- attribute :license, String, mapping: { index: 'not_analyzed' }
- attribute :licenses, String, default: [], mapping: { index: 'not_analyzed' }
- attribute :herds, String, default: [], mapping: { index: 'not_analyzed' }
+ raw_fields = {
+ type: 'keyword'
+ }
+
+ attribute :category, String, mapping: raw_fields
+ attribute :name, String, mapping: raw_fields
+ attribute :name_sort, String, mapping: raw_fields
+ attribute :atom, String, mapping: raw_fields
+ attribute :description, String, mapping: raw_fields
+ attribute :longdescription, String, mapping: raw_fields
+ attribute :homepage, String, default: [], mapping: raw_fields
+ attribute :license, String, mapping: raw_fields
+ attribute :licenses, String, default: [], mapping: raw_fields
+ attribute :herds, String, default: [], mapping: raw_fields
attribute :maintainers, Array, default: [], mapping: { type: 'object' }
attribute :useflags, Hash, default: {}, mapping: { type: 'object' }
- attribute :metadata_hash, String, mapping: { index: 'not_analyzed' }
+ attribute :metadata_hash, String, mapping: raw_fields
def category_model
@category_model ||= Category.find_by(:name, category)
diff --git a/app/models/useflag.rb b/app/models/useflag.rb
index 1139c97..65a7ecd 100644
--- a/app/models/useflag.rb
+++ b/app/models/useflag.rb
@@ -2,13 +2,13 @@ class Useflag
include Elasticsearch::Persistence::Model
include Kkuleomi::Store::Model
- index_name "packages-#{Rails.env}"
+ index_name "useflags-#{Rails.env}"
- attribute :name, String, mapping: { index: 'not_analyzed' }
- attribute :description, String
- attribute :atom, String, mapping: { index: 'not_analyzed' }
- attribute :scope, String, mapping: { index: 'not_analyzed' }
- attribute :use_expand_prefix, String, mapping: { index: 'not_analyzed' }
+ attribute :name, String, mapping: { type: 'text' }
+ attribute :description, String, mapping: { type: 'text' }
+ attribute :atom, String, mapping: { type: 'text' }
+ attribute :scope, String, mapping: { type: 'text' }
+ attribute :use_expand_prefix, String, mapping: { type: 'text' }
def all_fields
[:name, :description, :atom, :scope, :use_expand_prefix]
diff --git a/app/models/version.rb b/app/models/version.rb
index 1dc28f8..50d3940 100644
--- a/app/models/version.rb
+++ b/app/models/version.rb
@@ -3,21 +3,21 @@ class Version
include Kkuleomi::Store::Model
include Kkuleomi::Store::Models::VersionImport
- index_name "packages-#{Rails.env}"
-
- attribute :version, String, mapping: { index: 'not_analyzed' }
- attribute :package, String, mapping: { index: 'not_analyzed' }
- attribute :atom, String, mapping: { index: 'not_analyzed' }
- attribute :sort_key, Integer, mapping: { index: 'not_analyzed' }
- attribute :slot, String, mapping: { index: 'not_analyzed' }
- attribute :subslot, String, mapping: { index: 'not_analyzed' }
- attribute :eapi, String, mapping: { index: 'not_analyzed' }
- attribute :keywords, String, mapping: { index: 'not_analyzed' }
+ index_name "versions-#{Rails.env}"
+
+ attribute :version, String, mapping: { type: 'text' }
+ attribute :package, String, mapping: { type: 'text' }
+ attribute :atom, String, mapping: { type: 'text' }
+ attribute :sort_key, Integer, mapping: { type: 'text' }
+ attribute :slot, String, mapping: { type: 'text' }
+ attribute :subslot, String, mapping: { type: 'text' }
+ attribute :eapi, String, mapping: { type: 'text' }
+ attribute :keywords, String, mapping: { type: 'text' }
attribute :masks, Array, default: [], mapping: { type: 'object' }
- attribute :use, String, default: [], mapping: { index: 'not_analyzed' }
- attribute :restrict, String, default: [], mapping: { index: 'not_analyzed' }
- attribute :properties, String, default: [], mapping: { index: 'not_analyzed' }
- attribute :metadata_hash, String, mapping: { index: 'not_analyzed' }
+ attribute :use, String, default: [], mapping: { type: 'text' }
+ attribute :restrict, String, default: [], mapping: { type: 'text' }
+ attribute :properties, String, default: [], mapping: { type: 'text' }
+ attribute :metadata_hash, String, mapping: { type: 'text' }
# Returns the keywording state on a given architecture
#