Skip to content

Move char filters into analysis-common#24261

Merged
nik9000 merged 3 commits intoelastic:masterfrom
nik9000:modules_analysis_common_char_filters
Apr 26, 2017
Merged

Move char filters into analysis-common#24261
nik9000 merged 3 commits intoelastic:masterfrom
nik9000:modules_analysis_common_char_filters

Conversation

@nik9000
Copy link
Copy Markdown
Member

@nik9000 nik9000 commented Apr 21, 2017

Another step down the road to dropping the
lucene-analyzers-common dependency from core.

Note that this removes some tests that no longer compile from
core. I played around with adding them to the analysis-common
module where they would compile but we already test these in
the tests generated from the example usage in the documentation.

I'm not super happy with the way that requriesAnalysisSettings
works with regards to plugins. I think it'd be fairly bug-prone
for plugin authors to use. But I'm making it visible as is for
now and I'll rethink later.

A part of #23658

nik9000 added 3 commits April 21, 2017 11:08
Another step down the road to dropping the
lucene-analyzers-common dependency from core.

Note that this removes some tests that no longer compile from
core. I played around with adding them to the analysis-common
module where they would compile but we already test these in
the tests generated from the example usage in the documentation.

I'm not super happy with the way that `requriesAnalysisSettings`
works with regards to plugins. I think it'd be fairly bug-prone
for plugin authors to use. But I'm making it visible as is for
now and I'll rethink later.

A part of elastic#23658
One test was a duplicate of what is in analysis-common so I
dropped it. The other needed a mock normalize to do its job.
return normalizers;
}

private static <T> AnalysisModule.AnalysisProvider<T> requriesAnalysisSettings(AnalysisModule.AnalysisProvider<T> provider) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Move to AnalysisPlugin.


import static org.elasticsearch.test.ESTestCase.createTestAnalysis;

public class CharFilterTests extends ESTokenStreamTestCase {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These are duplicates of the rest tests in analysis-common. I can move this to analysis-common and keep it if anyone feels strongly about it.

return singletonMap("myfilter", MyFilterTokenFilterFactory::new);
}

@Override
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I believe this is a leftover. I'll look into removing this.

// verify characters mapping
analyzer = indexAnalyzers.get("custom5").analyzer();
assertThat(analyzer, instanceOf(CustomAnalyzer.class));
CustomAnalyzer custom5 = (CustomAnalyzer) analyzer;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I could recreate these with mock car filters if anyone feels strongly about it but I think we have these covered very well in other places.

assertThat(analyzeResponse.getTokens().get(0).getPositionLength(), equalTo(1));
}

public void testAnalyzeWithCharFilters() throws Exception {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Covered by the rest tests in analysis-common.

AnalyzeResponse analyzeResponse = admin().indices().prepareAnalyze().setIndex(indexOrAlias()).setText("THIS IS A PHISH")
.setExplain(true).addCharFilter("my_mapping").setTokenizer("keyword").addTokenFilter("lowercase").get();

assertThat(analyzeResponse.detail().analyzer(), IsNull.nullValue());
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Covered by the rest tests in analysis-common.

}

public void testDetailAnalyzeWithMultiValuesWithCustomAnalyzer() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Also covered by the rest tests in analysis-common.



public void testCustomCharFilterInRequest() throws Exception {
Map<String, Object> charFilterSettings = new HashMap<>();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Same.

Copy link
Copy Markdown
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM. There are certainly things I think we should cleanup eventually, like requiresAnalysisSettings(), but this change is just moving stuff around so I think it is good for now.

@nik9000 nik9000 merged commit 7c3efb8 into elastic:master Apr 26, 2017
@nik9000
Copy link
Copy Markdown
Member Author

nik9000 commented Apr 26, 2017

Thanks for reviewing @rjernst! I've merged to master only. No backporting for analysis-common.

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.

2 participants