-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to ES v1.5.2. Add url_decode option.
- Loading branch information
Showing
8 changed files
with
77 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
plugin=org.elasticsearch.plugin.analysis.AnalysisURLPlugin | ||
#lucene=${lucene.version} | ||
#lucene=${lucene.version} | ||
version=${project.version} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,14 +55,19 @@ public void testEmptyString() { | |
assertThat("no tokens", tokens, hasSize(0)); | ||
} | ||
|
||
@Test | ||
public void testUrlDecode() { | ||
assertURLAnalyzesTo("https://foo.bar.com?email=foo%40bar.com", "url_query", "[email protected]"); | ||
} | ||
|
||
private void refresh() { | ||
client().admin().indices().prepareRefresh().get(); | ||
} | ||
|
||
private void assertURLAnalyzesTo(String url, String analyzer, String expected) { | ||
List<AnalyzeResponse.AnalyzeToken> tokens = analyzeURL(url, analyzer); | ||
assertThat("a URL part was parsed", tokens, hasSize(1)); | ||
assertEquals("term value", tokens.get(0).getTerm(), expected); | ||
assertEquals("term value", expected, tokens.get(0).getTerm()); | ||
} | ||
|
||
private List<AnalyzeResponse.AnalyzeToken> analyzeURL(String url, String analyzer) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,12 +60,21 @@ public void testNullURL() throws IOException { | |
filter.incrementToken(); | ||
} | ||
|
||
@Test | ||
public void testUrlDecode() throws IOException { | ||
assertTokenStreamContents(createFilter("https://www.foo.com?email=foo%40bar.com", URLPart.QUERY, true), "[email protected]"); | ||
} | ||
|
||
private URLTokenFilter createFilter(final String url, final URLPart part) { | ||
return createFilter(url, part, false); | ||
} | ||
|
||
private URLTokenFilter createFilter(final String url, final URLPart part, final boolean urlDecode) { | ||
int length = 0; | ||
if (url != null) { | ||
length = url.length(); | ||
} | ||
return new URLTokenFilter(new SingleTokenTokenStream(new Token(url, 0, length)), part); | ||
return new URLTokenFilter(new SingleTokenTokenStream(new Token(url, 0, length)), part, urlDecode); | ||
} | ||
|
||
private static void assertTokenStreamContents(TokenStream in, String output) throws IOException { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters