Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Multiplexer inherit filter chains analysis mode #50662

Merged
merged 6 commits into from
Jan 8, 2020

Conversation

cbuescher
Copy link
Member

@cbuescher cbuescher commented Jan 6, 2020

Currently, if an updateable synonym filter is included in a multiplexer filter, it is not reloaded
via the _reload_search_analyzers because the multiplexer itself doesn't pass on the analysis mode
of the filters it contains, so its not recognized as "updateable" in itself. Instead we can check and merge
the AnalysisMode settings of all filters in the multiplexer and use the resulting mode (e.g. search-time only)
for the multiplexer itself, thus making any synonym filters contained in it reloadable. This, of course, will also
make the analyzers using the multiplexer be usable at search-time only.

Marking this as WIP for now to get some test runs and for discussion.

Closes #50554

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Analysis)

@cbuescher
Copy link
Member Author

@elasticmachine update branch

Copy link
Contributor

@romseygeek romseygeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cbuescher, looks good; there's one more test that I think is worth adding.

@@ -20,6 +20,7 @@
package org.elasticsearch.index.mapper;

import com.carrotsearch.hppc.ObjectHashSet;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think this is a leftover?

Comment on lines 126 to 138
String synonymsFileName = "synonyms.txt";
Path configDir = node().getEnvironment().configFile();
if (Files.exists(configDir) == false) {
Files.createDirectory(configDir);
}
Path synonymsFile = configDir.resolve(synonymsFileName);
if (Files.exists(synonymsFile) == false) {
Files.createFile(synonymsFile);
}
try (PrintWriter out = new PrintWriter(
new OutputStreamWriter(Files.newOutputStream(synonymsFile, StandardOpenOption.WRITE), StandardCharsets.UTF_8))) {
out.println("foo, baz");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this is reused in three different tests now, I wonder if it's worth extracting it as a separate method?

"Failed to parse mapping: analyzer [my_synonym_analyzer] "
+ "contains filters [synonym_filter] that are not allowed to run in all mode.",
ex.getMessage());
MapperException ex = expectThrows(MapperException.class,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This compression of multiple settings onto single lines seems to me to make test more difficult to follow, can we keep the indentation as it was before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, this was not intended, must be the new Eclipse installation doing some autoformatting.

response = client().prepareSearch(indexName).setQuery(QueryBuilders.matchQuery("field", "buzz")).get();
assertHitCount(response, 1L);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also add a test asserting that a multiplexer containing updateable synonyms is rejected as an index-time analyzer as well?

@cbuescher
Copy link
Member Author

@romseygeek thanks for the review, your comments should be adressed now

@cbuescher cbuescher removed the WIP label Jan 8, 2020
Copy link
Contributor

@romseygeek romseygeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @cbuescher!

@cbuescher cbuescher merged commit 4b366a4 into elastic:master Jan 8, 2020
cbuescher pushed a commit that referenced this pull request Jan 8, 2020
Currently, if an updateable synonym filter is included in a multiplexer filter,
it is not reloaded via the _reload_search_analyzers because the multiplexer
itself doesn't pass on the analysis mode of the filters it contains, so its not
recognized as "updateable" in itself. Instead we can check and merge the
AnalysisMode settings of all filters in the multiplexer and use the resulting
mode (e.g. search-time only) for the multiplexer itself, thus making any synonym
filters contained in it reloadable.  This, of course, will also make the
analyzers using the multiplexer be usable at search-time only.

Closes #50554
SivagurunathanV pushed a commit to SivagurunathanV/elasticsearch that referenced this pull request Jan 23, 2020
Currently, if an updateable synonym filter is included in a multiplexer filter, it is not reloaded via the 
_reload_search_analyzers because the multiplexer itself doesn't pass on the analysis mode of the 
filters it contains, so its not recognized as "updateable" in itself. Instead we can check and merge
the AnalysisMode settings of all filters in the multiplexer and use the resulting mode (e.g. search-time
only) for the multiplexer itself, thus making any synonym filters contained in it reloadable. 
This, of course, will also make the analyzers using the multiplexer be usable at search-time only.

Closes elastic#50554
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reload search analyzers does not work correctly with multiplexer filter (showstopper)
4 participants