Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

AO3-4815 Update Elasticsearch and filter interface #3104

Merged
merged 174 commits into from Oct 20, 2017

Conversation

Projects
None yet
7 participants
Contributor

WendyBeth commented Oct 13, 2017

Pull Request Checklist

  • Have you read How to write the perfect pull request?
  • Have you read through the contributor guidelines?
  • Have you added tests for any changed functionality?
  • Have you added the JIRA issue number as the first thing in your pull request title (eg: AO3-1234 Fix thing)
  • Have you updated the JIRA issue with the information below?

Issue

https://otwarchive.atlassian.net/browse/AO3-4815

Purpose

What does this PR do?

This PR

  • Adds code for indexing and queueing Elasticsearch indices for Elasticsearch version 5.6.1 (and is compatible, to the best of my knowledge, with 6.x)
  • Adds code to use rollout to split between Elasticsearch version and code usage
  • Adds exclusion filters to bookmarks and works

Testing

How can the Archive's QA team verify that this is working as you intended? (If you have access, please copy this into the JIRA ticket for them!)

Due to the extensive nature of this change, testing will require a full run-through of all search-related functionality on the site. This includes creating, updating, and deleting indices for all four searched models (Work, Bookmark, Pseud, and Tag) and all searching and filtering.

References

Are there any other relevant issues / PRs / mailing lists discussions related to this?

Credit

What name do you want us to use to credit your work in the Archive of Our Own's Release Notes?

Wendy Randquist - Littlelines

What pronouns do you prefer (she/her, he/him, zie/hir etc)?

she/her

(if you do not fill this in, we will use your GitHub account name and will use "they" to avoid making assumptions about your gender)

WendyBeth added some commits Aug 9, 2017

Adds elasticsearch-model to directly replace tire model
Uses rollout to indicate which module to include in the searchable modules
Fixes feature failure in importing
The image is rendered with https://, not http://
WIP - Pulls in elasticsearch overhaul code
Starting to debug elasticsearch overhaul code, both in its incompatibilities
with current ES and its underlying bugs.
Fixes other_a/orphan_work feature specs
Still using Tire, and reindexing with both Tire and elasticsearch will not break
anything and will be useful when running the test suite twice against the two
different ES versions
Reindexes indexes everywhere they are updated in the features directory
This should remove inconsistent, nearly-unrepeatable errors caused by the fact
that Elasticsearch is asynchronous. Yay!
Merge branch 'master' of https://github.com/littlelines/otwarchive in…
…to AO3-4815-update_elasticsearch_and_filter_interface

WendyBeth added some commits Sep 28, 2017

Makes Travis only run 2 trials
1 - With the old Elasticsearch, in which we test that the old Elasticsearch
continues to work while start_new_indexing is true (individual tests also test
that the SearchForm classes continue to work as expected, meaning that the new
Elasticsearch also works in this case when use_new_search is true)

2 - With the new Elasticsearch
Removes rollout manipulation from Travis
This was not actually setting features. All Travis needs to do is install one or
both versions of ES depending on the test group being run.
Removes default 'true' from use_new_search method
Reverts old styles and scripts to master
require 'spec_helper'
-describe WorkSearch do
+deprecate_old_elasticsearch_test do
+ describe WorkSearch do
@houndci-bot

houndci-bot Oct 13, 2017

Block has too many lines. [210/25]

end
- describe "when searching restricted works" do
+ describe '#search_results' do
@houndci-bot

houndci-bot Oct 13, 2017

Block has too many lines. [173/25]

+
+ # ES UPGRADE TRANSITION #
+ # Remove $rollout activation & unless block
+ $rollout.activate :start_new_indexing
@houndci-bot

houndci-bot Oct 13, 2017

Do not introduce global variables.

+ # Remove $rollout activation & unless block
+ $rollout.activate :start_new_indexing
+
+ unless elasticsearch_enabled?($elasticsearch)
@houndci-bot

houndci-bot Oct 13, 2017

Do not introduce global variables.

+ $rollout.activate :start_new_indexing
+
+ unless elasticsearch_enabled?($elasticsearch)
+ $rollout.activate :stop_old_indexing
@houndci-bot

houndci-bot Oct 13, 2017

Do not introduce global variables.

+
+ unless elasticsearch_enabled?($elasticsearch)
+ $rollout.activate :stop_old_indexing
+ $rollout.activate :use_new_search
@houndci-bot

houndci-bot Oct 13, 2017

Do not introduce global variables.

- Bookmark.tire.index.delete
- Bookmark.create_elasticsearch_index
+ ['work', 'bookmark', 'pseud', 'tag'].each do |index|
@houndci-bot

houndci-bot Oct 13, 2017

Use %w or %W for an array of words.

+# ES UPGRADE TRANSITION #
+# Remove method
+def elasticsearch_enabled?(elasticsearch_instance)
+ elasticsearch_instance.cluster.health rescue nil
@houndci-bot

houndci-bot Oct 13, 2017

Avoid using rescue in its modifier form.

+# ES UPGRADE TRANSITION #
+# Remove method
+def deprecate_old_elasticsearch_test
+ deprecate_unless(elasticsearch_enabled?($elasticsearch)) do
@houndci-bot

houndci-bot Oct 13, 2017

Do not introduce global variables.

+def update_and_refresh_indexes(klass_name)
+ # ES UPGRADE TRANSITION #
+ # Remove block
+ if elasticsearch_enabled?($elasticsearch)
@houndci-bot

houndci-bot Oct 13, 2017

Do not introduce global variables.

+ indexer = indexer_class.new(klass_name.capitalize.constantize.all.pluck(:id))
+ indexer.index_documents if klass_name.capitalize.constantize.any?
+
+ $new_elasticsearch.indices.refresh(index: "ao3_test_#{klass_name}s")
@houndci-bot

houndci-bot Oct 13, 2017

Do not introduce global variables.

+def delete_index(index)
+ # ES UPGRADE TRANSITION #
+ # Remove block
+ if elasticsearch_enabled?($elasticsearch)
@houndci-bot

houndci-bot Oct 13, 2017

Do not introduce global variables.

+
+ # NEW ES
+ index_name = "ao3_test_#{index}s"
+ if $new_elasticsearch.indices.exists? index: index_name
@houndci-bot

houndci-bot Oct 13, 2017

Do not introduce global variables.

+ # NEW ES
+ index_name = "ao3_test_#{index}s"
+ if $new_elasticsearch.indices.exists? index: index_name
+ $new_elasticsearch.indices.delete index: index_name
@houndci-bot

houndci-bot Oct 13, 2017

Do not introduce global variables.

+end
+
+def delete_test_indices
+ indices = $new_elasticsearch.indices.get_mapping.keys.select { |key| key.match("test") }
@houndci-bot

houndci-bot Oct 13, 2017

Do not introduce global variables.

+def delete_test_indices
+ indices = $new_elasticsearch.indices.get_mapping.keys.select { |key| key.match("test") }
+ indices.each do |index|
+ $new_elasticsearch.indices.delete(index: index)
@houndci-bot

houndci-bot Oct 13, 2017

Do not introduce global variables.

@ariana-paris ariana-paris changed the title from Ao3 4815 update elasticsearch and filter interface to AO3-4815 Update Elasticsearch and filter interface Oct 13, 2017

public/javascripts/application.js
@@ -644,17 +644,3 @@ function thermometer() {
}
});
}
-
-function updateCachedTokens() {
@redsummernight

redsummernight Oct 13, 2017

Contributor

Should this stay?

@elzj

elzj Oct 14, 2017

Owner

Yes, I'm wondering if this was the result of a merge conflict.

@sarken

sarken Oct 14, 2017

Owner

I think recent changes to the kudos function got overridden above (lines 457-468) as well, as did some recent CSS changes, which I'll comment on separately.

@@ -41,10 +41,6 @@ http://otwcode.github.com/docs/front_end_coding/patterns/supertypes
background: url("/images/ao3_logos/logo-ruby.png") top right no-repeat;
}
-#main.session {
@sarken

sarken Oct 14, 2017

Owner

I think this got removed accidentally -- it's a recent addition.

@@ -226,7 +226,6 @@ li.blurb:after, .blurb .blurb:after {
}
.claim .datetime {
- margin-left: 65px;
@sarken

sarken Oct 14, 2017

Owner

This is a recent change that should be kept.

@@ -212,8 +212,10 @@ SUBSECTIONS:
/* 2. ZONE: SYSTEM: SESSIONS (login and signup)*/
-.session #signin {
@sarken

sarken Oct 14, 2017

Owner

This should stay as

.session #signin {
  margin-left: 48%;
  width: 48%;
}
@@ -90,10 +90,6 @@ body .narrow-shown {
background-position: center;
}
-#main.session {
@sarken

sarken Oct 14, 2017

Owner

It looks like some recent changes got clobbered in a merge conflict -- the stuff that's being removed here should stay.

app/models/search/async_indexer.rb
@@ -14,6 +14,9 @@ def self.perform(name)
REDIS.del(name)
end
+ def self.index(klass, ids, priority)
@elzj

elzj Oct 18, 2017

Owner

Looks like this is missing some things - I just submitted a PR to your branch to flesh that out, since I was doing some batch indexing to test things out locally.

@@ -77,6 +79,73 @@ def process_options
self.options.delete_if { |key, value| value.blank? }
end
+ # Useful for inspecting the differences between the old ES query and the new
+ # ES query, when debugging problems between ES versions
+ def search_query
@elzj

elzj Oct 18, 2017

Owner

I always meant to split this out, and I agree that it's useful, but even for temp code, can we avoid duplicating this? I think the only difference between this code and the query in search_results is the lack of pagination here - is there any way to add that back and then just call search_query within search_results?

mapping do
indexes :id, index: :not_analyzed
- indexes :name, analyzer: 'snowball', boost: 100
+ indexes :name#, analyzer: 'snowball', boost: 100
@elzj

elzj Oct 18, 2017

Owner

Just checking that this is on purpose and not a typo

)
end
def pseud_ids
creatorships.pluck :pseud_id
end
+ def user_ids
+ Pseud.where(id: pseud_ids).pluck(:id)
@elzj

elzj Oct 18, 2017

Owner

I think this should be pluck(:user_id)

+ # Useful for inspecting the differences between the old ES query and the new
+ # ES query, when debugging problems between ES versions
+ def search_query
+ self.options ||= {}
@elzj

elzj Oct 18, 2017

Owner

Same comment as above re bookmark search.

WendyBeth added some commits Oct 18, 2017

Merge pull request #15 from elzj/AO3-4815-update_elasticsearch_and_fi…
…lter_interface

AO3-4815: Fill out new batch indexing code
+ }
+ }
+
+ $new_elasticsearch.reindex(body: request_body)
@houndci-bot

houndci-bot Oct 18, 2017

Do not introduce global variables.

+ end
+
+ def get_settings(index)
+ request = JSON.parse($elasticsearch.perform_request('GET', "#{index}/_settings").to_json)
@houndci-bot

houndci-bot Oct 18, 2017

Do not introduce global variables.

+ def make_mappings_compatible_with_new_es(mappings)
+ new_mappings = mappings.dup
+
+ new_mappings.each do |type, type_properties|
@houndci-bot

houndci-bot Oct 18, 2017

Unused block argument - type. If it's necessary, use _ or _type as an argument name to indicate that it won't be used.

+ properties = type_properties["properties"]
+
+ properties.keys.each do |key|
+
@houndci-bot

houndci-bot Oct 18, 2017

Extra empty line detected at block body beginning.

+ if properties[key] == "string"
+ properties[key] = "text"
+ end
+
@houndci-bot

houndci-bot Oct 18, 2017

Extra empty line detected at block body end.

+
+ new_mappings
+ end
+
@houndci-bot

houndci-bot Oct 18, 2017

Extra empty line detected at class body end.

@@ -16,9 +16,38 @@ def successful_reindex(ids)
def enqueue_to_index
if Rails.env.test?
- update_index and return
+ reindex_document and return
@houndci-bot

houndci-bot Oct 18, 2017

Use && instead of and.

+ def reindex_document
+ # ES UPGRADE TRANSITION #
+ # Remove `update_index rescue nil`
+ update_index rescue nil
@houndci-bot

houndci-bot Oct 18, 2017

Avoid using rescue in its modifier form.

+ # ES UPGRADE TRANSITION #
+ # Remove outer conditional
+ if self.class.use_new_search?
+ index_name = self.is_a?(Tag) ? 'tag' : self.class.to_s.downcase
@houndci-bot

houndci-bot Oct 18, 2017

Redundant self detected.

+ # Remove outer conditional
+ if self.class.use_new_search?
+ index_name = self.is_a?(Tag) ? 'tag' : self.class.to_s.downcase
+ doc_type = self.is_a?(Tag) ? 'tag' : self.class.document_type
@houndci-bot

houndci-bot Oct 18, 2017

Redundant self detected.

+ index = {
+ index: "ao3_#{Rails.env}_#{index_name}s",
+ type: doc_type,
+ id: self.id,
@houndci-bot

houndci-bot Oct 18, 2017

Redundant self detected.

+ index: "ao3_#{Rails.env}_#{index_name}s",
+ type: doc_type,
+ id: self.id,
+ body: self.document_json
@houndci-bot

houndci-bot Oct 18, 2017

Redundant self detected.

+ body: self.document_json
+ }
+
+ if self.is_a?(Bookmark)
@houndci-bot

houndci-bot Oct 18, 2017

Redundant self detected.

+ }
+
+ if self.is_a?(Bookmark)
+ index.merge!(
@houndci-bot

houndci-bot Oct 18, 2017

Use index[:routing] = "#{self.bookmarkable_type}-#{self.bookmarkable_id}" instead of `index.merge!(

+
+ if self.is_a?(Bookmark)
+ index.merge!(
+ routing: "#{self.bookmarkable_type}-#{self.bookmarkable_id}"
@houndci-bot

houndci-bot Oct 18, 2017

Redundant self detected.

+
+ # ES UPGRADE TRANSITION #
+ # Replace $new_elasticsearch with $elasticsearch
+ $new_elasticsearch.index index
@houndci-bot

houndci-bot Oct 18, 2017

Do not introduce global variables.

+ work_search = self
+
+ search = Tire.search 'work' do
+ query do
@houndci-bot

houndci-bot Oct 18, 2017

Block has too many lines. [27/25]

+ must { terms :pseud_ids, search_opts[:pseud_ids] }
+ end
+
+ [:rating_ids, :warning_ids, :category_ids, :fandom_ids, :character_ids, :relationship_ids, :freeform_ids].each do |id_list|
@houndci-bot

houndci-bot Oct 18, 2017

Use %i or %I for an array of symbols.

+ end
+ end
+
+ [:filter_ids, :collection_ids].each do |id_list|
@houndci-bot

houndci-bot Oct 18, 2017

Use %i or %I for an array of symbols.

+ end
+
+ [:filter_ids, :collection_ids].each do |id_list|
+ if search_opts[id_list].present?
@houndci-bot

houndci-bot Oct 18, 2017

Use next to skip iteration.

+ end
+ end
+
+ [:word_count, :hits, :kudos_count, :comments_count, :bookmarks_count, :revised_at].each do |countable|
@houndci-bot

houndci-bot Oct 18, 2017

Use %i or %I for an array of symbols.

+# ES UPGRADE TRANSITION #
+# Remove $new_elasticsearch definition, since ELASTICSEARCH_1_URL should point
+# to new ES instance
@houndci-bot

houndci-bot Oct 18, 2017

Do not introduce global variables.

+# Remove $new_elasticsearch definition, since ELASTICSEARCH_1_URL should point
+# to new ES instance
+$elasticsearch = Elasticsearch::Client.new host: ArchiveConfig.ELASTICSEARCH_1_URL
@houndci-bot

houndci-bot Oct 18, 2017

Do not introduce global variables.

@@ -9,7 +9,7 @@
step %{I start a new bookmark for "#{title}"}
fill_in("bookmark_tag_string", with: DEFAULT_BOOKMARK_TAGS)
step %{I press "Create"}
- Bookmark.tire.index.refresh
+ step %{the bookmark indexes are updated}
@houndci-bot

houndci-bot Oct 18, 2017

Inconsistent indentation detected.

@@ -179,6 +179,7 @@
step %{I follow "Collection Settings"}
step %{I uncheck "This collection is anonymous"}
step %{I press "Update"}
+ step %{the work indexes are updated}
@houndci-bot

houndci-bot Oct 18, 2017

Inconsistent indentation detected.

@@ -1,12 +1,34 @@
+require "cucumber/rspec/doubles"
@houndci-bot

houndci-bot Oct 18, 2017

Missing magic comment # frozen_string_literal: true.

+ es_update(klass)
+ # ES UPGRADE TRANSITION #
+ # Remove unless block
+ unless !elasticsearch_enabled?($elasticsearch)
@houndci-bot

houndci-bot Oct 18, 2017

Favor if over unless for negative conditions.
Do not introduce global variables.

- [Work, Bookmark, Pseud, Tag].each do |klass|
- klass.import
- klass.tire.index.refresh
+ ['work', 'bookmark', 'pseud', 'tag'].each do |klass|
@houndci-bot

houndci-bot Oct 18, 2017

Use %w or %W for an array of words.

+Given /^the (\w+) indexes are reindexed$/ do |model|
+ # ES UPGRADE TRANSITION #
+ # Change $new_elasticsearch to $elasticsearch
+ $new_elasticsearch.indices.refresh index: "ao3_test_#{model}s"
@houndci-bot

houndci-bot Oct 18, 2017

Do not introduce global variables.

end
+Given /^all search indexes are reindexed$/ do
+ ['work', 'bookmark', 'pseud', 'tag'].each do |model|
@houndci-bot

houndci-bot Oct 18, 2017

Use %w or %W for an array of words.

+
+When /^(\w+) can use the new search/ do |login|
+ user = User.find_by(login: login)
+ $rollout.activate_user(:use_new_search, user)
@houndci-bot

houndci-bot Oct 18, 2017

Do not introduce global variables.

Owner

elzj commented Oct 20, 2017

Okay, merging this and we can submit new pull requests with further updates.

@elzj elzj merged commit 40cd564 into otwcode:master Oct 20, 2017

2 of 3 checks passed

codeclimate 42 issues to fix
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
hound 489 violations found.
Contributor

hatal175 commented Oct 31, 2017

Currently, the new elasticsearch is not installed on the vagrant machine, so all tests fail on it.
I managed to run them but it required changing several places in the code...

zz9pzza added a commit that referenced this pull request Nov 27, 2017

Re-merge Elasticsearch branch (#3179)
* AO3-4815 Update Elasticsearch and filter interface (#3104)

* Upgrades faraday (ran bundle update elasticsearch)

* Adds elasticsearch-model to directly replace tire model

Uses rollout to indicate which module to include in the searchable modules

* Allows application to connect to two ES instances

* Switches version of ES in use by Indexer and Query depending on rollout feature

* Fixes feature failure in importing

The image is rendered with https://, not http://

* Adds awesome_print gem, to make inspecting json easier

* Adds class to recreate indices in upgraded ES instance & reindex from remote

* Removes elasticsearch-model

* Removes rollout code from models

* WIP - Making app compatible with ES 5.5

* WIP - Pulls in elasticsearch overhaul code

Starting to debug elasticsearch overhaul code, both in its incompatibilities
with current ES and its underlying bugs.

* Gets search/works_anonymous feature specs to pass with new ES code

* Gets search/works_tags features to pass with new es code

* Fixes search/works_info spec failures

* Fixes test failures in search/work_stats

* Updates ES version read by Travis

* Updates ES instance to point to the url Travis will recognize

* Fixes some failing feature specs for search

* Fixes admins/admin_works specs

* Fixes bookmark_create and collection_dashboard feature specs

* Fixes importing/archivist feature specs

* Fixes other_a/orphan_work feature specs

Still using Tire, and reindexing with both Tire and elasticsearch will not break
anything and will be useful when running the test suite twice against the two
different ES versions

* Fixes all other other_a feature failures

* Fixes works_anonymous feature failures

* Fixes tag_wrangling_relationships feature failures

* Fixes users feature failures

* Fixes works feature failures

* Adds the new ES indexing code wherever Tire is use in test setup

* Fixes works default rails actions spec failures

* Fixes elasticsearch_upgrade_spec failures and refactors ES refresh code

* Fixes work query spec

* Adds some minor refactoring to tests

* Adds bookmark indexing/query code & fixes associated tests

* Updates BookmarkSearch references to BookmarkSearchForm

* Fixes bookmark_create feature failures

* Fixes admin/admin_works feature failures

* Fixes bookmarks feature spec failures

* Fixes collections feature specs

* Fixes other_a and search failures

* Fixes users feature specs

* Removes refrences to tire from tests and specs for now

* Fixes search steps problem when reindexing models with any? false

* Fixes reindexing models without any records in specs

* Removes outdated use of WorkSearch model in works controller

* Fixes typo

* Fixes failing specs caused by fixes to failing features

* Fixes bugs in bookmark query

* Some feature failure cleanup

* Adds code for Tag search using updated ES

* Adds pseud search code

* Small test fixes

* Fixes some failing tests, and attempts to address Travis issues

* Adds fixes for Travis failures that are repeatable locally

* Fixes problem where bookmarks without works can't be searched for

* Reindexes indexes everywhere they are updated in the features directory

This should remove inconsistent, nearly-unrepeatable errors caused by the fact
that Elasticsearch is asynchronous. Yay!

* Fixes bookmark query spec failure

* Refactors some of the index updating logic in features

* Fixes default rails actions for works spec

* Isolates Tire reindexing to one file in features

* Fixes tags and wrangling test failures

* Distinguishes ES versions in specs

* Fixes some typos

* Updates to catch old ES version no matter the environment

* Attempting a run with old ES version

* Fixes Tire import

* Fixes spec helper method

* Separates ES wrappers based on ES version in controllers

* Fixes use of new ES code in helpers for use_old_search?

* Fixes old ES code usage in bookmarks controller

* Fixes search using old ES for bookmarks

* Removes tests that were catching a bug that is no longer a problem

* Fixes works failures for old es version

* Fixes features failing on Travis

* Fixes spec failures for old ES version

* Sets Travis to dl new version of ES to see how build does

* Attempt with ES 6.0 alpha

* Adds fix for bookmark deletion bug

* Adds missing details to work indexer

* Adds rollout to indexing

* Swaps out 'use_old_search?' with 'use_new_search?'

* Fixes param names in tests

* Adds rollout to application record use_new_search? method

* Fixes small details & removes unused code

* Fixes typo

* Fixes typo

* Fixes typo

* Fixes lack of question mark for rollout.active? method

* Runs Travis build on old ES and sets elasticsearch version with rollout

* Fixes inccorect method invocation

* Fixes incorrect method invocation in people controller

* Fixes works stats feature failures

* Adds fixes for failing specs

* Uses appropriate count method for old es version

* Removes debug line from feature

* Upgrades nokogiri due to security concern

* Makes it so app will respond appropriately to ES version

To run on Travis, all three ES urls need to be the same:
ENV['ELASTICSEARCH_URL'] &
ENV['ELASTICSEARCH_1_URL'] &
ENV['UPGRADED_ELASTICSEARCH_URL']

All need to point to the same thing. Whenever running an instance of the app
with two versions of ES, ENV['ELASTICSEARCH_URL'] and ENV['ELASTICSEARCH_1_URL']
need to point to the old version and ENV['UPGRADED_ELASTICSEARCH_URL'] needs to
point to the new version.

* Second attempt with 6.0.0-alpha1 ES

* For test with ES 6.0.0-alpha1

* Fixes Travis run in 6.0.0-alpha1 ES

* Untar

* Try starting both

* Simple test run

* Differentiate the builds

* Differentiate the builds

* Restore all the tests

* Fixes call to new elasticsearch api perform_request

* Updates to test suite to watch how upgraded es version works on its own

* refactors out index updating methods in feature specs

* Adds rollout specs

* Fixes bug in work search form object

* Matches config to travis

* Removes all but rspec tests from travis for now

* Sets up tests & rollout methods use expected behavior

* Fixes switch from string to text or keyword for index definitions

* Updates index definitions to be compatible with 6.0.0.beta2 ES version

* Changes localhost to home IP for old ES urls

* Does not require old es to work when old es is gone

* Switches ES bool queries to true/false

* Fixes spec failures for ES Group 1

* Adds specific test to ensure old elasticsearch does not index when it's not present

* Moves to new elasticsearch document indexing when old es is gone

* Fixes problem with helper method for specs

* Ensures app never attempts to reindex an old es index in the new es instance

* Makes it so that a user doesn't have to be present if use_new_search is 100% enabled

* Runs ES=1

* Runs ES=2

* Runs ES=3

* Runs ES=4

* Back to rspec

* Removes command to rebuild three times upon failure

* Updates set_rollout script to use global  variable

* Adds rollout definitions to test suite to see if that addresses Travis build problem

* Runs build with ES=1

* Runs all builds

* Adds same assurances to features as specs that ES will work w/ both versions

* Fixes imported image URL in feature spec

* Fixes reference to tire methods when tire is gone in feature support methods

* Runs only ES=4

* Moves es/rollout code for feature specs

* Fixes boolean representation in work search form

* Fixes boolean in ES search in bookmark search form

* Fixes bookmarks feature failures

* Fixes works_restricted feature failures

* Runs all four ES groups

* Runs ES=1 and ES=4

* Comments out test that's breaking due to third-party url bug

* Makes Travis only run 2 trials

1 - With the old Elasticsearch, in which we test that the old Elasticsearch
continues to work while start_new_indexing is true (individual tests also test
that the SearchForm classes continue to work as expected, meaning that the new
Elasticsearch also works in this case when use_new_search is true)

2 - With the new Elasticsearch

* Adds old exlclusion filter code

* Adds tests & code for work filtering with exclusion tags

* Addresses Travis test failures

* Adds bookmark exclusion filters

* Downgrades back to 5.6.1 (latest stable) ES version

* Adds single_mapping => true to ES indices

* Fixes failure to index bookmarks when they do not have a bookmarkable object

* Adds comments to help when removing old code

* Removes rollout manipulation from Travis

This was not actually setting features. All Travis needs to do is install one or
both versions of ES depending on the test group being run.

* Adds test cases for use_new_search? controller method

* Adds tests & fixes bugs for filtering

* Removes default 'true' from use_new_search method

Reverts old styles and scripts to master

* Fixes typos

* Fixes more typos

* Fixes rollout test for works controller

* Fixes works controller mistake

* Ports over ALL js and css changes that effect filters

* Removes useless method

* Removes file that has nothing to do with new search

* Fixes failing filter tests

* Pulls in fix for autocomplete bug from master

* AO3-4815: Fill out new batch indexing code

* Fixes merge clobbering of css & js files

* AO3-4815: Add new ES to codeship script and use local.yml instead of … (#3110)

* AO3-4815: Add new ES to codeship script and use local.yml instead of editing the regular config

* Fix ES download url and load local config when testing

* AO3-4815: Ensure correct results when browsing bookmarks by user (#3109)

* AO3-5213 Index authors on works correctly for sorting (#3114)

AO3-5213 Index authors on works correctly for sorting

* AO3-5207 Add StatCounterIndexer and fix order of reindexing. (#3111)

* AO3-5207 First go at StatCounter reindexing.

* AO3-5207 Add RSpec tests to make sure it works.

* AO3-5207 Small fixes to pass tests.

* AO3-5207 Make sure to call original when stubbing.

* AO3-5207 Finally fixed.

* AO3-5212 Index correct user ids for works. Also throw in a couple of updated work type tag ids (#3112)

* AO3-5209 Don't change the appearance of non-work & bookmark filters (#3117)

* AO3-5209 Use old JavaScript and views for old Elasticsearch filters (styling fixes to come)

* AO3-5209 Restyle old filters

* AO3-5209 Ensure new work and bookmark filter styling does not conflict with exisiting collection filter styles

* AO3-5216 Fix setting authenticity tokens when cached pages load (#3118)

This was the fix for AO3-5153, which got lost in a merge.

* AO3-5214 Only run the tests on Travis once for now (#3116)

* AO3-5208: Fix filtering behavior (#3113)

* AO3-5208: Fix filtering behavior by drilling down and setting facets appropriately.

* AO3-5208: Don't error when there are no filters

* AO3-5208: Ensure excluded tags are visible in filters

* AO3-5208: Make sure bookmark facet query knows about exclusions. Also don't index filters and other bookmarkable fields on the bookmark itself since that's what we're trying to avoid.

* AO3-5208: Dry up some tag-related query methods, reduce number of db requests, only exclude children of Character tags, and make exclusion work for bookmark tags again

* AO3-5208: Update some tests to match new behavior

* AO3-5208: Put excluded bookmark tags in the right filter bucket

* AO3-5208: Remove sub tag exclusion code, since the meta tag id is already indexed on works

* AO3-5208: Comment out tests for types of exclusion filtering we aren't currently doing for bookmarks

* AO3-5208: Enable querying on both parent and child bookmark fields and reflect queries in bookmark filters

* AO3-5208: Update tests for bookmark search syntax change and bookmarker indexing encompassing user name

* AO3-5208: Make 'other tags' filtering work for noncanonical tags as well

* AO3-5223: Fix id on bookmarks exclude field

* AO3-5208: Remove child exclusion from filters and enable inclusion for noncanonical tags

* AO3-5220 and AO3-5224: Fix searching bookmarks by notes and tag names and index bookmarkable date for sorting

* AO3-5220: Update old bookmark search code for notes fix, fix spacing in module

* AO3-5225 Fix sidebar counts and scope by user id if a user is present (#3119)

* AO3-5225: Fix sidebar counts and scope by user id if a user is present

* AO3-5225: Update user dashboard feature to check counts in multiple places

* AO3-5231: Fix formatting of search text and don't chop up tag searches

* AO3-5231: Remove duplication and add specs

sarken added a commit that referenced this pull request Nov 27, 2017

AO3-5254: Upgrade to Elasticsearch 6 (#3183)
* AO3-4815 Update Elasticsearch and filter interface (#3104)

* Upgrades faraday (ran bundle update elasticsearch)

* Adds elasticsearch-model to directly replace tire model

Uses rollout to indicate which module to include in the searchable modules

* Allows application to connect to two ES instances

* Switches version of ES in use by Indexer and Query depending on rollout feature

* Fixes feature failure in importing

The image is rendered with https://, not http://

* Adds awesome_print gem, to make inspecting json easier

* Adds class to recreate indices in upgraded ES instance & reindex from remote

* Removes elasticsearch-model

* Removes rollout code from models

* WIP - Making app compatible with ES 5.5

* WIP - Pulls in elasticsearch overhaul code

Starting to debug elasticsearch overhaul code, both in its incompatibilities
with current ES and its underlying bugs.

* Gets search/works_anonymous feature specs to pass with new ES code

* Gets search/works_tags features to pass with new es code

* Fixes search/works_info spec failures

* Fixes test failures in search/work_stats

* Updates ES version read by Travis

* Updates ES instance to point to the url Travis will recognize

* Fixes some failing feature specs for search

* Fixes admins/admin_works specs

* Fixes bookmark_create and collection_dashboard feature specs

* Fixes importing/archivist feature specs

* Fixes other_a/orphan_work feature specs

Still using Tire, and reindexing with both Tire and elasticsearch will not break
anything and will be useful when running the test suite twice against the two
different ES versions

* Fixes all other other_a feature failures

* Fixes works_anonymous feature failures

* Fixes tag_wrangling_relationships feature failures

* Fixes users feature failures

* Fixes works feature failures

* Adds the new ES indexing code wherever Tire is use in test setup

* Fixes works default rails actions spec failures

* Fixes elasticsearch_upgrade_spec failures and refactors ES refresh code

* Fixes work query spec

* Adds some minor refactoring to tests

* Adds bookmark indexing/query code & fixes associated tests

* Updates BookmarkSearch references to BookmarkSearchForm

* Fixes bookmark_create feature failures

* Fixes admin/admin_works feature failures

* Fixes bookmarks feature spec failures

* Fixes collections feature specs

* Fixes other_a and search failures

* Fixes users feature specs

* Removes refrences to tire from tests and specs for now

* Fixes search steps problem when reindexing models with any? false

* Fixes reindexing models without any records in specs

* Removes outdated use of WorkSearch model in works controller

* Fixes typo

* Fixes failing specs caused by fixes to failing features

* Fixes bugs in bookmark query

* Some feature failure cleanup

* Adds code for Tag search using updated ES

* Adds pseud search code

* Small test fixes

* Fixes some failing tests, and attempts to address Travis issues

* Adds fixes for Travis failures that are repeatable locally

* Fixes problem where bookmarks without works can't be searched for

* Reindexes indexes everywhere they are updated in the features directory

This should remove inconsistent, nearly-unrepeatable errors caused by the fact
that Elasticsearch is asynchronous. Yay!

* Fixes bookmark query spec failure

* Refactors some of the index updating logic in features

* Fixes default rails actions for works spec

* Isolates Tire reindexing to one file in features

* Fixes tags and wrangling test failures

* Distinguishes ES versions in specs

* Fixes some typos

* Updates to catch old ES version no matter the environment

* Attempting a run with old ES version

* Fixes Tire import

* Fixes spec helper method

* Separates ES wrappers based on ES version in controllers

* Fixes use of new ES code in helpers for use_old_search?

* Fixes old ES code usage in bookmarks controller

* Fixes search using old ES for bookmarks

* Removes tests that were catching a bug that is no longer a problem

* Fixes works failures for old es version

* Fixes features failing on Travis

* Fixes spec failures for old ES version

* Sets Travis to dl new version of ES to see how build does

* Attempt with ES 6.0 alpha

* Adds fix for bookmark deletion bug

* Adds missing details to work indexer

* Adds rollout to indexing

* Swaps out 'use_old_search?' with 'use_new_search?'

* Fixes param names in tests

* Adds rollout to application record use_new_search? method

* Fixes small details & removes unused code

* Fixes typo

* Fixes typo

* Fixes typo

* Fixes lack of question mark for rollout.active? method

* Runs Travis build on old ES and sets elasticsearch version with rollout

* Fixes inccorect method invocation

* Fixes incorrect method invocation in people controller

* Fixes works stats feature failures

* Adds fixes for failing specs

* Uses appropriate count method for old es version

* Removes debug line from feature

* Upgrades nokogiri due to security concern

* Makes it so app will respond appropriately to ES version

To run on Travis, all three ES urls need to be the same:
ENV['ELASTICSEARCH_URL'] &
ENV['ELASTICSEARCH_1_URL'] &
ENV['UPGRADED_ELASTICSEARCH_URL']

All need to point to the same thing. Whenever running an instance of the app
with two versions of ES, ENV['ELASTICSEARCH_URL'] and ENV['ELASTICSEARCH_1_URL']
need to point to the old version and ENV['UPGRADED_ELASTICSEARCH_URL'] needs to
point to the new version.

* Second attempt with 6.0.0-alpha1 ES

* For test with ES 6.0.0-alpha1

* Fixes Travis run in 6.0.0-alpha1 ES

* Untar

* Try starting both

* Simple test run

* Differentiate the builds

* Differentiate the builds

* Restore all the tests

* Fixes call to new elasticsearch api perform_request

* Updates to test suite to watch how upgraded es version works on its own

* refactors out index updating methods in feature specs

* Adds rollout specs

* Fixes bug in work search form object

* Matches config to travis

* Removes all but rspec tests from travis for now

* Sets up tests & rollout methods use expected behavior

* Fixes switch from string to text or keyword for index definitions

* Updates index definitions to be compatible with 6.0.0.beta2 ES version

* Changes localhost to home IP for old ES urls

* Does not require old es to work when old es is gone

* Switches ES bool queries to true/false

* Fixes spec failures for ES Group 1

* Adds specific test to ensure old elasticsearch does not index when it's not present

* Moves to new elasticsearch document indexing when old es is gone

* Fixes problem with helper method for specs

* Ensures app never attempts to reindex an old es index in the new es instance

* Makes it so that a user doesn't have to be present if use_new_search is 100% enabled

* Runs ES=1

* Runs ES=2

* Runs ES=3

* Runs ES=4

* Back to rspec

* Removes command to rebuild three times upon failure

* Updates set_rollout script to use global  variable

* Adds rollout definitions to test suite to see if that addresses Travis build problem

* Runs build with ES=1

* Runs all builds

* Adds same assurances to features as specs that ES will work w/ both versions

* Fixes imported image URL in feature spec

* Fixes reference to tire methods when tire is gone in feature support methods

* Runs only ES=4

* Moves es/rollout code for feature specs

* Fixes boolean representation in work search form

* Fixes boolean in ES search in bookmark search form

* Fixes bookmarks feature failures

* Fixes works_restricted feature failures

* Runs all four ES groups

* Runs ES=1 and ES=4

* Comments out test that's breaking due to third-party url bug

* Makes Travis only run 2 trials

1 - With the old Elasticsearch, in which we test that the old Elasticsearch
continues to work while start_new_indexing is true (individual tests also test
that the SearchForm classes continue to work as expected, meaning that the new
Elasticsearch also works in this case when use_new_search is true)

2 - With the new Elasticsearch

* Adds old exlclusion filter code

* Adds tests & code for work filtering with exclusion tags

* Addresses Travis test failures

* Adds bookmark exclusion filters

* Downgrades back to 5.6.1 (latest stable) ES version

* Adds single_mapping => true to ES indices

* Fixes failure to index bookmarks when they do not have a bookmarkable object

* Adds comments to help when removing old code

* Removes rollout manipulation from Travis

This was not actually setting features. All Travis needs to do is install one or
both versions of ES depending on the test group being run.

* Adds test cases for use_new_search? controller method

* Adds tests & fixes bugs for filtering

* Removes default 'true' from use_new_search method

Reverts old styles and scripts to master

* Fixes typos

* Fixes more typos

* Fixes rollout test for works controller

* Fixes works controller mistake

* Ports over ALL js and css changes that effect filters

* Removes useless method

* Removes file that has nothing to do with new search

* Fixes failing filter tests

* Pulls in fix for autocomplete bug from master

* AO3-4815: Fill out new batch indexing code

* Fixes merge clobbering of css & js files

* AO3-4815: Add new ES to codeship script and use local.yml instead of … (#3110)

* AO3-4815: Add new ES to codeship script and use local.yml instead of editing the regular config

* Fix ES download url and load local config when testing

* AO3-4815: Ensure correct results when browsing bookmarks by user (#3109)

* AO3-5213 Index authors on works correctly for sorting (#3114)

AO3-5213 Index authors on works correctly for sorting

* AO3-5207 Add StatCounterIndexer and fix order of reindexing. (#3111)

* AO3-5207 First go at StatCounter reindexing.

* AO3-5207 Add RSpec tests to make sure it works.

* AO3-5207 Small fixes to pass tests.

* AO3-5207 Make sure to call original when stubbing.

* AO3-5207 Finally fixed.

* AO3-5212 Index correct user ids for works. Also throw in a couple of updated work type tag ids (#3112)

* AO3-5209 Don't change the appearance of non-work & bookmark filters (#3117)

* AO3-5209 Use old JavaScript and views for old Elasticsearch filters (styling fixes to come)

* AO3-5209 Restyle old filters

* AO3-5209 Ensure new work and bookmark filter styling does not conflict with exisiting collection filter styles

* AO3-5216 Fix setting authenticity tokens when cached pages load (#3118)

This was the fix for AO3-5153, which got lost in a merge.

* AO3-5214 Only run the tests on Travis once for now (#3116)

* AO3-5208: Fix filtering behavior (#3113)

* AO3-5208: Fix filtering behavior by drilling down and setting facets appropriately.

* AO3-5208: Don't error when there are no filters

* AO3-5208: Ensure excluded tags are visible in filters

* AO3-5208: Make sure bookmark facet query knows about exclusions. Also don't index filters and other bookmarkable fields on the bookmark itself since that's what we're trying to avoid.

* AO3-5208: Dry up some tag-related query methods, reduce number of db requests, only exclude children of Character tags, and make exclusion work for bookmark tags again

* AO3-5208: Update some tests to match new behavior

* AO3-5208: Put excluded bookmark tags in the right filter bucket

* AO3-5208: Remove sub tag exclusion code, since the meta tag id is already indexed on works

* AO3-5208: Comment out tests for types of exclusion filtering we aren't currently doing for bookmarks

* AO3-5208: Enable querying on both parent and child bookmark fields and reflect queries in bookmark filters

* AO3-5208: Update tests for bookmark search syntax change and bookmarker indexing encompassing user name

* AO3-5208: Make 'other tags' filtering work for noncanonical tags as well

* AO3-5223: Fix id on bookmarks exclude field

* AO3-5208: Remove child exclusion from filters and enable inclusion for noncanonical tags

* AO3-5220 and AO3-5224: Fix searching bookmarks by notes and tag names and index bookmarkable date for sorting

* AO3-5220: Update old bookmark search code for notes fix, fix spacing in module

* AO3-5225 Fix sidebar counts and scope by user id if a user is present (#3119)

* AO3-5225: Fix sidebar counts and scope by user id if a user is present

* AO3-5225: Update user dashboard feature to check counts in multiple places

* AO3-5231: Fix formatting of search text and don't chop up tag searches

* AO3-5231: Remove duplication and add specs

* Upgrade elasticsearch version on travis

* Remove single type mapping which is no longer needed

* Update has_parent query syntax

* Update syntax for parent and child filters, which are now only supported as queries

* Update bookmark query spec to match new syntax

* Upgrade codeship

sarken added a commit that referenced this pull request Nov 30, 2017

AO3-5221: Bookmarkable indexing (#3186)
* AO3-4815 Update Elasticsearch and filter interface (#3104)

* Upgrades faraday (ran bundle update elasticsearch)

* Adds elasticsearch-model to directly replace tire model

Uses rollout to indicate which module to include in the searchable modules

* Allows application to connect to two ES instances

* Switches version of ES in use by Indexer and Query depending on rollout feature

* Fixes feature failure in importing

The image is rendered with https://, not http://

* Adds awesome_print gem, to make inspecting json easier

* Adds class to recreate indices in upgraded ES instance & reindex from remote

* Removes elasticsearch-model

* Removes rollout code from models

* WIP - Making app compatible with ES 5.5

* WIP - Pulls in elasticsearch overhaul code

Starting to debug elasticsearch overhaul code, both in its incompatibilities
with current ES and its underlying bugs.

* Gets search/works_anonymous feature specs to pass with new ES code

* Gets search/works_tags features to pass with new es code

* Fixes search/works_info spec failures

* Fixes test failures in search/work_stats

* Updates ES version read by Travis

* Updates ES instance to point to the url Travis will recognize

* Fixes some failing feature specs for search

* Fixes admins/admin_works specs

* Fixes bookmark_create and collection_dashboard feature specs

* Fixes importing/archivist feature specs

* Fixes other_a/orphan_work feature specs

Still using Tire, and reindexing with both Tire and elasticsearch will not break
anything and will be useful when running the test suite twice against the two
different ES versions

* Fixes all other other_a feature failures

* Fixes works_anonymous feature failures

* Fixes tag_wrangling_relationships feature failures

* Fixes users feature failures

* Fixes works feature failures

* Adds the new ES indexing code wherever Tire is use in test setup

* Fixes works default rails actions spec failures

* Fixes elasticsearch_upgrade_spec failures and refactors ES refresh code

* Fixes work query spec

* Adds some minor refactoring to tests

* Adds bookmark indexing/query code & fixes associated tests

* Updates BookmarkSearch references to BookmarkSearchForm

* Fixes bookmark_create feature failures

* Fixes admin/admin_works feature failures

* Fixes bookmarks feature spec failures

* Fixes collections feature specs

* Fixes other_a and search failures

* Fixes users feature specs

* Removes refrences to tire from tests and specs for now

* Fixes search steps problem when reindexing models with any? false

* Fixes reindexing models without any records in specs

* Removes outdated use of WorkSearch model in works controller

* Fixes typo

* Fixes failing specs caused by fixes to failing features

* Fixes bugs in bookmark query

* Some feature failure cleanup

* Adds code for Tag search using updated ES

* Adds pseud search code

* Small test fixes

* Fixes some failing tests, and attempts to address Travis issues

* Adds fixes for Travis failures that are repeatable locally

* Fixes problem where bookmarks without works can't be searched for

* Reindexes indexes everywhere they are updated in the features directory

This should remove inconsistent, nearly-unrepeatable errors caused by the fact
that Elasticsearch is asynchronous. Yay!

* Fixes bookmark query spec failure

* Refactors some of the index updating logic in features

* Fixes default rails actions for works spec

* Isolates Tire reindexing to one file in features

* Fixes tags and wrangling test failures

* Distinguishes ES versions in specs

* Fixes some typos

* Updates to catch old ES version no matter the environment

* Attempting a run with old ES version

* Fixes Tire import

* Fixes spec helper method

* Separates ES wrappers based on ES version in controllers

* Fixes use of new ES code in helpers for use_old_search?

* Fixes old ES code usage in bookmarks controller

* Fixes search using old ES for bookmarks

* Removes tests that were catching a bug that is no longer a problem

* Fixes works failures for old es version

* Fixes features failing on Travis

* Fixes spec failures for old ES version

* Sets Travis to dl new version of ES to see how build does

* Attempt with ES 6.0 alpha

* Adds fix for bookmark deletion bug

* Adds missing details to work indexer

* Adds rollout to indexing

* Swaps out 'use_old_search?' with 'use_new_search?'

* Fixes param names in tests

* Adds rollout to application record use_new_search? method

* Fixes small details & removes unused code

* Fixes typo

* Fixes typo

* Fixes typo

* Fixes lack of question mark for rollout.active? method

* Runs Travis build on old ES and sets elasticsearch version with rollout

* Fixes inccorect method invocation

* Fixes incorrect method invocation in people controller

* Fixes works stats feature failures

* Adds fixes for failing specs

* Uses appropriate count method for old es version

* Removes debug line from feature

* Upgrades nokogiri due to security concern

* Makes it so app will respond appropriately to ES version

To run on Travis, all three ES urls need to be the same:
ENV['ELASTICSEARCH_URL'] &
ENV['ELASTICSEARCH_1_URL'] &
ENV['UPGRADED_ELASTICSEARCH_URL']

All need to point to the same thing. Whenever running an instance of the app
with two versions of ES, ENV['ELASTICSEARCH_URL'] and ENV['ELASTICSEARCH_1_URL']
need to point to the old version and ENV['UPGRADED_ELASTICSEARCH_URL'] needs to
point to the new version.

* Second attempt with 6.0.0-alpha1 ES

* For test with ES 6.0.0-alpha1

* Fixes Travis run in 6.0.0-alpha1 ES

* Untar

* Try starting both

* Simple test run

* Differentiate the builds

* Differentiate the builds

* Restore all the tests

* Fixes call to new elasticsearch api perform_request

* Updates to test suite to watch how upgraded es version works on its own

* refactors out index updating methods in feature specs

* Adds rollout specs

* Fixes bug in work search form object

* Matches config to travis

* Removes all but rspec tests from travis for now

* Sets up tests & rollout methods use expected behavior

* Fixes switch from string to text or keyword for index definitions

* Updates index definitions to be compatible with 6.0.0.beta2 ES version

* Changes localhost to home IP for old ES urls

* Does not require old es to work when old es is gone

* Switches ES bool queries to true/false

* Fixes spec failures for ES Group 1

* Adds specific test to ensure old elasticsearch does not index when it's not present

* Moves to new elasticsearch document indexing when old es is gone

* Fixes problem with helper method for specs

* Ensures app never attempts to reindex an old es index in the new es instance

* Makes it so that a user doesn't have to be present if use_new_search is 100% enabled

* Runs ES=1

* Runs ES=2

* Runs ES=3

* Runs ES=4

* Back to rspec

* Removes command to rebuild three times upon failure

* Updates set_rollout script to use global  variable

* Adds rollout definitions to test suite to see if that addresses Travis build problem

* Runs build with ES=1

* Runs all builds

* Adds same assurances to features as specs that ES will work w/ both versions

* Fixes imported image URL in feature spec

* Fixes reference to tire methods when tire is gone in feature support methods

* Runs only ES=4

* Moves es/rollout code for feature specs

* Fixes boolean representation in work search form

* Fixes boolean in ES search in bookmark search form

* Fixes bookmarks feature failures

* Fixes works_restricted feature failures

* Runs all four ES groups

* Runs ES=1 and ES=4

* Comments out test that's breaking due to third-party url bug

* Makes Travis only run 2 trials

1 - With the old Elasticsearch, in which we test that the old Elasticsearch
continues to work while start_new_indexing is true (individual tests also test
that the SearchForm classes continue to work as expected, meaning that the new
Elasticsearch also works in this case when use_new_search is true)

2 - With the new Elasticsearch

* Adds old exlclusion filter code

* Adds tests & code for work filtering with exclusion tags

* Addresses Travis test failures

* Adds bookmark exclusion filters

* Downgrades back to 5.6.1 (latest stable) ES version

* Adds single_mapping => true to ES indices

* Fixes failure to index bookmarks when they do not have a bookmarkable object

* Adds comments to help when removing old code

* Removes rollout manipulation from Travis

This was not actually setting features. All Travis needs to do is install one or
both versions of ES depending on the test group being run.

* Adds test cases for use_new_search? controller method

* Adds tests & fixes bugs for filtering

* Removes default 'true' from use_new_search method

Reverts old styles and scripts to master

* Fixes typos

* Fixes more typos

* Fixes rollout test for works controller

* Fixes works controller mistake

* Ports over ALL js and css changes that effect filters

* Removes useless method

* Removes file that has nothing to do with new search

* Fixes failing filter tests

* Pulls in fix for autocomplete bug from master

* AO3-4815: Fill out new batch indexing code

* Fixes merge clobbering of css & js files

* AO3-4815: Add new ES to codeship script and use local.yml instead of … (#3110)

* AO3-4815: Add new ES to codeship script and use local.yml instead of editing the regular config

* Fix ES download url and load local config when testing

* AO3-4815: Ensure correct results when browsing bookmarks by user (#3109)

* AO3-5213 Index authors on works correctly for sorting (#3114)

AO3-5213 Index authors on works correctly for sorting

* AO3-5207 Add StatCounterIndexer and fix order of reindexing. (#3111)

* AO3-5207 First go at StatCounter reindexing.

* AO3-5207 Add RSpec tests to make sure it works.

* AO3-5207 Small fixes to pass tests.

* AO3-5207 Make sure to call original when stubbing.

* AO3-5207 Finally fixed.

* AO3-5212 Index correct user ids for works. Also throw in a couple of updated work type tag ids (#3112)

* AO3-5209 Don't change the appearance of non-work & bookmark filters (#3117)

* AO3-5209 Use old JavaScript and views for old Elasticsearch filters (styling fixes to come)

* AO3-5209 Restyle old filters

* AO3-5209 Ensure new work and bookmark filter styling does not conflict with exisiting collection filter styles

* AO3-5216 Fix setting authenticity tokens when cached pages load (#3118)

This was the fix for AO3-5153, which got lost in a merge.

* AO3-5214 Only run the tests on Travis once for now (#3116)

* AO3-5208: Fix filtering behavior (#3113)

* AO3-5208: Fix filtering behavior by drilling down and setting facets appropriately.

* AO3-5208: Don't error when there are no filters

* AO3-5208: Ensure excluded tags are visible in filters

* AO3-5208: Make sure bookmark facet query knows about exclusions. Also don't index filters and other bookmarkable fields on the bookmark itself since that's what we're trying to avoid.

* AO3-5208: Dry up some tag-related query methods, reduce number of db requests, only exclude children of Character tags, and make exclusion work for bookmark tags again

* AO3-5208: Update some tests to match new behavior

* AO3-5208: Put excluded bookmark tags in the right filter bucket

* AO3-5208: Remove sub tag exclusion code, since the meta tag id is already indexed on works

* AO3-5208: Comment out tests for types of exclusion filtering we aren't currently doing for bookmarks

* AO3-5208: Enable querying on both parent and child bookmark fields and reflect queries in bookmark filters

* AO3-5208: Update tests for bookmark search syntax change and bookmarker indexing encompassing user name

* AO3-5208: Make 'other tags' filtering work for noncanonical tags as well

* AO3-5223: Fix id on bookmarks exclude field

* AO3-5208: Remove child exclusion from filters and enable inclusion for noncanonical tags

* AO3-5220 and AO3-5224: Fix searching bookmarks by notes and tag names and index bookmarkable date for sorting

* AO3-5220: Update old bookmark search code for notes fix, fix spacing in module

* AO3-5225 Fix sidebar counts and scope by user id if a user is present (#3119)

* AO3-5225: Fix sidebar counts and scope by user id if a user is present

* AO3-5225: Update user dashboard feature to check counts in multiple places

* AO3-5221: Set up a pathway from bookmarked classes to our indexers

* AO3-5221: Fix code that got re-added on merge

* AO3-5221: Do a little method delegation

* AO3-5221: Make sure stat counter indexing still works

* AO3-5221: Update comments

ariana-paris added a commit to ariana-paris/otwarchive that referenced this pull request Dec 3, 2017

AO3-4815 Update Elasticsearch and filter interface (#3104)
* Upgrades faraday (ran bundle update elasticsearch)

* Adds elasticsearch-model to directly replace tire model

Uses rollout to indicate which module to include in the searchable modules

* Allows application to connect to two ES instances

* Switches version of ES in use by Indexer and Query depending on rollout feature

* Fixes feature failure in importing

The image is rendered with https://, not http://

* Adds awesome_print gem, to make inspecting json easier

* Adds class to recreate indices in upgraded ES instance & reindex from remote

* Removes elasticsearch-model

* Removes rollout code from models

* WIP - Making app compatible with ES 5.5

* WIP - Pulls in elasticsearch overhaul code

Starting to debug elasticsearch overhaul code, both in its incompatibilities
with current ES and its underlying bugs.

* Gets search/works_anonymous feature specs to pass with new ES code

* Gets search/works_tags features to pass with new es code

* Fixes search/works_info spec failures

* Fixes test failures in search/work_stats

* Updates ES version read by Travis

* Updates ES instance to point to the url Travis will recognize

* Fixes some failing feature specs for search

* Fixes admins/admin_works specs

* Fixes bookmark_create and collection_dashboard feature specs

* Fixes importing/archivist feature specs

* Fixes other_a/orphan_work feature specs

Still using Tire, and reindexing with both Tire and elasticsearch will not break
anything and will be useful when running the test suite twice against the two
different ES versions

* Fixes all other other_a feature failures

* Fixes works_anonymous feature failures

* Fixes tag_wrangling_relationships feature failures

* Fixes users feature failures

* Fixes works feature failures

* Adds the new ES indexing code wherever Tire is use in test setup

* Fixes works default rails actions spec failures

* Fixes elasticsearch_upgrade_spec failures and refactors ES refresh code

* Fixes work query spec

* Adds some minor refactoring to tests

* Adds bookmark indexing/query code & fixes associated tests

* Updates BookmarkSearch references to BookmarkSearchForm

* Fixes bookmark_create feature failures

* Fixes admin/admin_works feature failures

* Fixes bookmarks feature spec failures

* Fixes collections feature specs

* Fixes other_a and search failures

* Fixes users feature specs

* Removes refrences to tire from tests and specs for now

* Fixes search steps problem when reindexing models with any? false

* Fixes reindexing models without any records in specs

* Removes outdated use of WorkSearch model in works controller

* Fixes typo

* Fixes failing specs caused by fixes to failing features

* Fixes bugs in bookmark query

* Some feature failure cleanup

* Adds code for Tag search using updated ES

* Adds pseud search code

* Small test fixes

* Fixes some failing tests, and attempts to address Travis issues

* Adds fixes for Travis failures that are repeatable locally

* Fixes problem where bookmarks without works can't be searched for

* Reindexes indexes everywhere they are updated in the features directory

This should remove inconsistent, nearly-unrepeatable errors caused by the fact
that Elasticsearch is asynchronous. Yay!

* Fixes bookmark query spec failure

* Refactors some of the index updating logic in features

* Fixes default rails actions for works spec

* Isolates Tire reindexing to one file in features

* Fixes tags and wrangling test failures

* Distinguishes ES versions in specs

* Fixes some typos

* Updates to catch old ES version no matter the environment

* Attempting a run with old ES version

* Fixes Tire import

* Fixes spec helper method

* Separates ES wrappers based on ES version in controllers

* Fixes use of new ES code in helpers for use_old_search?

* Fixes old ES code usage in bookmarks controller

* Fixes search using old ES for bookmarks

* Removes tests that were catching a bug that is no longer a problem

* Fixes works failures for old es version

* Fixes features failing on Travis

* Fixes spec failures for old ES version

* Sets Travis to dl new version of ES to see how build does

* Attempt with ES 6.0 alpha

* Adds fix for bookmark deletion bug

* Adds missing details to work indexer

* Adds rollout to indexing

* Swaps out 'use_old_search?' with 'use_new_search?'

* Fixes param names in tests

* Adds rollout to application record use_new_search? method

* Fixes small details & removes unused code

* Fixes typo

* Fixes typo

* Fixes typo

* Fixes lack of question mark for rollout.active? method

* Runs Travis build on old ES and sets elasticsearch version with rollout

* Fixes inccorect method invocation

* Fixes incorrect method invocation in people controller

* Fixes works stats feature failures

* Adds fixes for failing specs

* Uses appropriate count method for old es version

* Removes debug line from feature

* Upgrades nokogiri due to security concern

* Makes it so app will respond appropriately to ES version

To run on Travis, all three ES urls need to be the same:
ENV['ELASTICSEARCH_URL'] &
ENV['ELASTICSEARCH_1_URL'] &
ENV['UPGRADED_ELASTICSEARCH_URL']

All need to point to the same thing. Whenever running an instance of the app
with two versions of ES, ENV['ELASTICSEARCH_URL'] and ENV['ELASTICSEARCH_1_URL']
need to point to the old version and ENV['UPGRADED_ELASTICSEARCH_URL'] needs to
point to the new version.

* Second attempt with 6.0.0-alpha1 ES

* For test with ES 6.0.0-alpha1

* Fixes Travis run in 6.0.0-alpha1 ES

* Untar

* Try starting both

* Simple test run

* Differentiate the builds

* Differentiate the builds

* Restore all the tests

* Fixes call to new elasticsearch api perform_request

* Updates to test suite to watch how upgraded es version works on its own

* refactors out index updating methods in feature specs

* Adds rollout specs

* Fixes bug in work search form object

* Matches config to travis

* Removes all but rspec tests from travis for now

* Sets up tests & rollout methods use expected behavior

* Fixes switch from string to text or keyword for index definitions

* Updates index definitions to be compatible with 6.0.0.beta2 ES version

* Changes localhost to home IP for old ES urls

* Does not require old es to work when old es is gone

* Switches ES bool queries to true/false

* Fixes spec failures for ES Group 1

* Adds specific test to ensure old elasticsearch does not index when it's not present

* Moves to new elasticsearch document indexing when old es is gone

* Fixes problem with helper method for specs

* Ensures app never attempts to reindex an old es index in the new es instance

* Makes it so that a user doesn't have to be present if use_new_search is 100% enabled

* Runs ES=1

* Runs ES=2

* Runs ES=3

* Runs ES=4

* Back to rspec

* Removes command to rebuild three times upon failure

* Updates set_rollout script to use global  variable

* Adds rollout definitions to test suite to see if that addresses Travis build problem

* Runs build with ES=1

* Runs all builds

* Adds same assurances to features as specs that ES will work w/ both versions

* Fixes imported image URL in feature spec

* Fixes reference to tire methods when tire is gone in feature support methods

* Runs only ES=4

* Moves es/rollout code for feature specs

* Fixes boolean representation in work search form

* Fixes boolean in ES search in bookmark search form

* Fixes bookmarks feature failures

* Fixes works_restricted feature failures

* Runs all four ES groups

* Runs ES=1 and ES=4

* Comments out test that's breaking due to third-party url bug

* Makes Travis only run 2 trials

1 - With the old Elasticsearch, in which we test that the old Elasticsearch
continues to work while start_new_indexing is true (individual tests also test
that the SearchForm classes continue to work as expected, meaning that the new
Elasticsearch also works in this case when use_new_search is true)

2 - With the new Elasticsearch

* Adds old exlclusion filter code

* Adds tests & code for work filtering with exclusion tags

* Addresses Travis test failures

* Adds bookmark exclusion filters

* Downgrades back to 5.6.1 (latest stable) ES version

* Adds single_mapping => true to ES indices

* Fixes failure to index bookmarks when they do not have a bookmarkable object

* Adds comments to help when removing old code

* Removes rollout manipulation from Travis

This was not actually setting features. All Travis needs to do is install one or
both versions of ES depending on the test group being run.

* Adds test cases for use_new_search? controller method

* Adds tests & fixes bugs for filtering

* Removes default 'true' from use_new_search method

Reverts old styles and scripts to master

* Fixes typos

* Fixes more typos

* Fixes rollout test for works controller

* Fixes works controller mistake

* Ports over ALL js and css changes that effect filters

* Removes useless method

* Removes file that has nothing to do with new search

* Fixes failing filter tests

* Pulls in fix for autocomplete bug from master

* AO3-4815: Fill out new batch indexing code

* Fixes merge clobbering of css & js files

ariana-paris added a commit to ariana-paris/otwarchive that referenced this pull request Dec 3, 2017

AO3-4815 Update Elasticsearch and filter interface (#3104)
* Upgrades faraday (ran bundle update elasticsearch)

* Adds elasticsearch-model to directly replace tire model

Uses rollout to indicate which module to include in the searchable modules

* Allows application to connect to two ES instances

* Switches version of ES in use by Indexer and Query depending on rollout feature

* Fixes feature failure in importing

The image is rendered with https://, not http://

* Adds awesome_print gem, to make inspecting json easier

* Adds class to recreate indices in upgraded ES instance & reindex from remote

* Removes elasticsearch-model

* Removes rollout code from models

* WIP - Making app compatible with ES 5.5

* WIP - Pulls in elasticsearch overhaul code

Starting to debug elasticsearch overhaul code, both in its incompatibilities
with current ES and its underlying bugs.

* Gets search/works_anonymous feature specs to pass with new ES code

* Gets search/works_tags features to pass with new es code

* Fixes search/works_info spec failures

* Fixes test failures in search/work_stats

* Updates ES version read by Travis

* Updates ES instance to point to the url Travis will recognize

* Fixes some failing feature specs for search

* Fixes admins/admin_works specs

* Fixes bookmark_create and collection_dashboard feature specs

* Fixes importing/archivist feature specs

* Fixes other_a/orphan_work feature specs

Still using Tire, and reindexing with both Tire and elasticsearch will not break
anything and will be useful when running the test suite twice against the two
different ES versions

* Fixes all other other_a feature failures

* Fixes works_anonymous feature failures

* Fixes tag_wrangling_relationships feature failures

* Fixes users feature failures

* Fixes works feature failures

* Adds the new ES indexing code wherever Tire is use in test setup

* Fixes works default rails actions spec failures

* Fixes elasticsearch_upgrade_spec failures and refactors ES refresh code

* Fixes work query spec

* Adds some minor refactoring to tests

* Adds bookmark indexing/query code & fixes associated tests

* Updates BookmarkSearch references to BookmarkSearchForm

* Fixes bookmark_create feature failures

* Fixes admin/admin_works feature failures

* Fixes bookmarks feature spec failures

* Fixes collections feature specs

* Fixes other_a and search failures

* Fixes users feature specs

* Removes refrences to tire from tests and specs for now

* Fixes search steps problem when reindexing models with any? false

* Fixes reindexing models without any records in specs

* Removes outdated use of WorkSearch model in works controller

* Fixes typo

* Fixes failing specs caused by fixes to failing features

* Fixes bugs in bookmark query

* Some feature failure cleanup

* Adds code for Tag search using updated ES

* Adds pseud search code

* Small test fixes

* Fixes some failing tests, and attempts to address Travis issues

* Adds fixes for Travis failures that are repeatable locally

* Fixes problem where bookmarks without works can't be searched for

* Reindexes indexes everywhere they are updated in the features directory

This should remove inconsistent, nearly-unrepeatable errors caused by the fact
that Elasticsearch is asynchronous. Yay!

* Fixes bookmark query spec failure

* Refactors some of the index updating logic in features

* Fixes default rails actions for works spec

* Isolates Tire reindexing to one file in features

* Fixes tags and wrangling test failures

* Distinguishes ES versions in specs

* Fixes some typos

* Updates to catch old ES version no matter the environment

* Attempting a run with old ES version

* Fixes Tire import

* Fixes spec helper method

* Separates ES wrappers based on ES version in controllers

* Fixes use of new ES code in helpers for use_old_search?

* Fixes old ES code usage in bookmarks controller

* Fixes search using old ES for bookmarks

* Removes tests that were catching a bug that is no longer a problem

* Fixes works failures for old es version

* Fixes features failing on Travis

* Fixes spec failures for old ES version

* Sets Travis to dl new version of ES to see how build does

* Attempt with ES 6.0 alpha

* Adds fix for bookmark deletion bug

* Adds missing details to work indexer

* Adds rollout to indexing

* Swaps out 'use_old_search?' with 'use_new_search?'

* Fixes param names in tests

* Adds rollout to application record use_new_search? method

* Fixes small details & removes unused code

* Fixes typo

* Fixes typo

* Fixes typo

* Fixes lack of question mark for rollout.active? method

* Runs Travis build on old ES and sets elasticsearch version with rollout

* Fixes inccorect method invocation

* Fixes incorrect method invocation in people controller

* Fixes works stats feature failures

* Adds fixes for failing specs

* Uses appropriate count method for old es version

* Removes debug line from feature

* Upgrades nokogiri due to security concern

* Makes it so app will respond appropriately to ES version

To run on Travis, all three ES urls need to be the same:
ENV['ELASTICSEARCH_URL'] &
ENV['ELASTICSEARCH_1_URL'] &
ENV['UPGRADED_ELASTICSEARCH_URL']

All need to point to the same thing. Whenever running an instance of the app
with two versions of ES, ENV['ELASTICSEARCH_URL'] and ENV['ELASTICSEARCH_1_URL']
need to point to the old version and ENV['UPGRADED_ELASTICSEARCH_URL'] needs to
point to the new version.

* Second attempt with 6.0.0-alpha1 ES

* For test with ES 6.0.0-alpha1

* Fixes Travis run in 6.0.0-alpha1 ES

* Untar

* Try starting both

* Simple test run

* Differentiate the builds

* Differentiate the builds

* Restore all the tests

* Fixes call to new elasticsearch api perform_request

* Updates to test suite to watch how upgraded es version works on its own

* refactors out index updating methods in feature specs

* Adds rollout specs

* Fixes bug in work search form object

* Matches config to travis

* Removes all but rspec tests from travis for now

* Sets up tests & rollout methods use expected behavior

* Fixes switch from string to text or keyword for index definitions

* Updates index definitions to be compatible with 6.0.0.beta2 ES version

* Changes localhost to home IP for old ES urls

* Does not require old es to work when old es is gone

* Switches ES bool queries to true/false

* Fixes spec failures for ES Group 1

* Adds specific test to ensure old elasticsearch does not index when it's not present

* Moves to new elasticsearch document indexing when old es is gone

* Fixes problem with helper method for specs

* Ensures app never attempts to reindex an old es index in the new es instance

* Makes it so that a user doesn't have to be present if use_new_search is 100% enabled

* Runs ES=1

* Runs ES=2

* Runs ES=3

* Runs ES=4

* Back to rspec

* Removes command to rebuild three times upon failure

* Updates set_rollout script to use global  variable

* Adds rollout definitions to test suite to see if that addresses Travis build problem

* Runs build with ES=1

* Runs all builds

* Adds same assurances to features as specs that ES will work w/ both versions

* Fixes imported image URL in feature spec

* Fixes reference to tire methods when tire is gone in feature support methods

* Runs only ES=4

* Moves es/rollout code for feature specs

* Fixes boolean representation in work search form

* Fixes boolean in ES search in bookmark search form

* Fixes bookmarks feature failures

* Fixes works_restricted feature failures

* Runs all four ES groups

* Runs ES=1 and ES=4

* Comments out test that's breaking due to third-party url bug

* Makes Travis only run 2 trials

1 - With the old Elasticsearch, in which we test that the old Elasticsearch
continues to work while start_new_indexing is true (individual tests also test
that the SearchForm classes continue to work as expected, meaning that the new
Elasticsearch also works in this case when use_new_search is true)

2 - With the new Elasticsearch

* Adds old exlclusion filter code

* Adds tests & code for work filtering with exclusion tags

* Addresses Travis test failures

* Adds bookmark exclusion filters

* Downgrades back to 5.6.1 (latest stable) ES version

* Adds single_mapping => true to ES indices

* Fixes failure to index bookmarks when they do not have a bookmarkable object

* Adds comments to help when removing old code

* Removes rollout manipulation from Travis

This was not actually setting features. All Travis needs to do is install one or
both versions of ES depending on the test group being run.

* Adds test cases for use_new_search? controller method

* Adds tests & fixes bugs for filtering

* Removes default 'true' from use_new_search method

Reverts old styles and scripts to master

* Fixes typos

* Fixes more typos

* Fixes rollout test for works controller

* Fixes works controller mistake

* Ports over ALL js and css changes that effect filters

* Removes useless method

* Removes file that has nothing to do with new search

* Fixes failing filter tests

* Pulls in fix for autocomplete bug from master

* AO3-4815: Fill out new batch indexing code

* Fixes merge clobbering of css & js files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment