-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1367 from iadcode/master
Add option to set path to custom tika config file
- Loading branch information
Showing
12 changed files
with
300 additions
and
56 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
55 changes: 55 additions & 0 deletions
55
...lasticsearch/crawler/fs/test/integration/elasticsearch/FsCrawlerTestTikaConfigPathIT.java
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Licensed to David Pilato (the "Author") under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. Author licenses this | ||
* file to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package fr.pilato.elasticsearch.crawler.fs.test.integration.elasticsearch; | ||
|
||
import fr.pilato.elasticsearch.crawler.fs.client.ESMatchQuery; | ||
import fr.pilato.elasticsearch.crawler.fs.client.ESSearchRequest; | ||
import fr.pilato.elasticsearch.crawler.fs.settings.Fs; | ||
import fr.pilato.elasticsearch.crawler.fs.test.integration.AbstractFsCrawlerITCase; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Test tika config path crawler setting | ||
*/ | ||
public class FsCrawlerTestTikaConfigPathIT extends AbstractFsCrawlerITCase { | ||
|
||
@Test | ||
public void test_tika_config_path() throws Exception { | ||
Fs fs = startCrawlerDefinition() | ||
.setTikaConfigPath(currentTestResourceDir.resolve("config/tikaConfig.xml").toString()) | ||
.addExclude("/config/*") | ||
.build(); | ||
startCrawler(getCrawlerName(), fs, endCrawlerDefinition(getCrawlerName()), null); | ||
|
||
countTestHelper(new ESSearchRequest().withIndex(getCrawlerName()), 2L, null); | ||
countTestHelper(new ESSearchRequest() | ||
.withIndex(getCrawlerName()) | ||
.withESQuery(new ESMatchQuery("content", "Tika")), 2L, null); | ||
// HTML parsed as TXT will contain all tags in content | ||
// XHTML parsed as XML will remove tags from content | ||
countTestHelper(new ESSearchRequest() | ||
.withIndex(getCrawlerName()) | ||
.withESQuery(new ESMatchQuery("content", "div")), 1L, null); | ||
countTestHelper(new ESSearchRequest() | ||
.withIndex(getCrawlerName()) | ||
.withESQuery(new ESMatchQuery("meta.title", "Test Tika title")), 0L, null); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...s/it-common/src/main/resources-binary/samples/test_tika_config_path/config/tikaConfig.xml
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<properties> | ||
<service-loader dynamic="true"/> | ||
<service-loader loadErrorHandler="IGNORE"/> | ||
<parsers> | ||
<!-- Default Parser, but never use HTML parser --> | ||
<parser class="org.apache.tika.parser.DefaultParser"> | ||
<parser-exclude class="org.apache.tika.parser.html.HtmlParser"/> | ||
</parser> | ||
<!-- Use a different parser for XHTML --> | ||
<parser class="org.apache.tika.parser.xml.XMLParser"> | ||
<mime>application/xhtml+xml</mime> | ||
</parser> | ||
</parsers> | ||
</properties> |
15 changes: 15 additions & 0 deletions
15
...gration-tests/it-common/src/main/resources-binary/samples/test_tika_config_path/test.html
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<html | ||
xmlns:o="urn:schemas-microsoft-com:office:office" | ||
xmlns="http://www.w3.org/TR/REC-html40"> | ||
|
||
<head> | ||
<title>Test Tika title</title> | ||
</head> | ||
|
||
<body> | ||
<p>This is an example of HTML</p> | ||
<div /> | ||
<p>This is a separate line</p> | ||
</body> | ||
|
||
</html> |
17 changes: 17 additions & 0 deletions
17
...ration-tests/it-common/src/main/resources-binary/samples/test_tika_config_path/test.xhtml
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE html> | ||
<html | ||
xmlns:o="urn:schemas-microsoft-com:office:office" | ||
xmlns="http://www.w3.org/TR/REC-html40"> | ||
|
||
<head> | ||
<title>Test Tika title</title> | ||
</head> | ||
|
||
<body> | ||
<p>This is an example of XHTML</p> | ||
<div /> | ||
<p>This is a separate line</p> | ||
</body> | ||
|
||
</html> |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<properties> | ||
<service-loader dynamic="true"/> | ||
<service-loader loadErrorHandler="IGNORE"/> | ||
<parsers> | ||
<!-- Default Parser, but never use HTML parser --> | ||
<parser class="org.apache.tika.parser.DefaultParser"> | ||
<parser-exclude class="org.apache.tika.parser.html.HtmlParser"/> | ||
</parser> | ||
<!-- Use a different parser for XHTML --> | ||
<parser class="org.apache.tika.parser.xml.XMLParser"> | ||
<mime>application/xhtml+xml</mime> | ||
</parser> | ||
</parsers> | ||
</properties> |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE html> | ||
<html | ||
xmlns:o="urn:schemas-microsoft-com:office:office" | ||
xmlns="http://www.w3.org/TR/REC-html40"> | ||
|
||
<head> | ||
<title>Test Tika title</title> | ||
</head> | ||
|
||
<body> | ||
<p>This is an example of XHTML</p> | ||
<div /> | ||
<p>This is a separate line</p> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.