Skip to content

Commit

Permalink
NUTCH-1928 Indexing filter of documents by the MIME type
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/nutch/trunk@1661600 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
jorgelbg committed Feb 23, 2015
1 parent b477bcb commit c059485
Show file tree
Hide file tree
Showing 11 changed files with 499 additions and 1 deletion.
4 changes: 4 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
<packageset dir="${plugins.dir}/index-more/src/java"/>
<packageset dir="${plugins.dir}/index-geoip/src/java"/>
<packageset dir="${plugins.dir}/index-static/src/java"/>
<packageset dir="${plugins.dir}/mimetype-filter/src/java"/>
<packageset dir="${plugins.dir}/indexer-dummy/src/java"/>
<packageset dir="${plugins.dir}/indexer-elastic/src/java/" />
<packageset dir="${plugins.dir}/indexer-solr/src/java"/>
Expand Down Expand Up @@ -584,6 +585,7 @@
<packageset dir="${plugins.dir}/index-metadata/src/java"/>
<packageset dir="${plugins.dir}/index-more/src/java"/>
<packageset dir="${plugins.dir}/index-static/src/java"/>
<packageset dir="${plugins.dir}/mimetype-filter/src/java"/>
<packageset dir="${plugins.dir}/indexer-dummy/src/java"/>
<packageset dir="${plugins.dir}/indexer-elastic/src/java/" />
<packageset dir="${plugins.dir}/indexer-solr/src/java"/>
Expand Down Expand Up @@ -969,6 +971,8 @@
<source path="${plugins.dir}/index-basic/src/test/" />
<source path="${plugins.dir}/index-geoip/src/java/" />
<source path="${plugins.dir}/index-geoip/src/test/" />
<source path="${plugins.dir}/mimetype-filter/src/java/" />
<source path="${plugins.dir}/mimetype-filter/src/test/" />
<source path="${plugins.dir}/indexer-dummy/src/java/" />
<source path="${plugins.dir}/indexer-solr/src/java/" />
<source path="${plugins.dir}/indexer-elastic/src/java/" />
Expand Down
11 changes: 11 additions & 0 deletions conf/nutch-default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1602,4 +1602,15 @@
<description>Whether to support multivalued headings.</description>
</property>

<!-- mimetype-filter plugin properties -->

<property>
<name>mimetype.filter.file</name>
<value>mimetype-filter.txt</value>
<description>
The configuration file for the mimetype-filter plugin. This file contains
the rules used to allow or deny the indexing of certain documents.
</description>
</property>

</configuration>
1 change: 1 addition & 0 deletions default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ plugins.index=\
org.apache.nutch.indexer.basic*:\
org.apache.nutch.indexer.feed*:\
org.apache.nutch.indexer.geoip*:\
org.apache.nutch.indexer.filter*:\
org.apache.nutch.indexer.metadata*:\
org.apache.nutch.indexer.more*:\
org.apache.nutch.indexer.static*:\
Expand Down
5 changes: 4 additions & 1 deletion src/plugin/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<ant dir="index-more" target="deploy"/>
<ant dir="index-static" target="deploy"/>
<ant dir="index-metadata" target="deploy"/>
<ant dir="mimetype-filter" target="deploy"/>
<ant dir="indexer-dummy" target="deploy"/>
<ant dir="indexer-elastic" target="deploy"/>
<ant dir="indexer-solr" target="deploy"/>
Expand Down Expand Up @@ -88,6 +89,7 @@
<ant dir="index-geoip" target="test"/>
<ant dir="index-more" target="test"/>
<ant dir="index-static" target="test"/>
<ant dir="mimetype-filter" target="test"/>
<ant dir="language-identifier" target="test"/>
<ant dir="lib-http" target="test"/>
<ant dir="protocol-file" target="test"/>
Expand Down Expand Up @@ -126,10 +128,11 @@
<ant dir="headings" target="clean"/>
<ant dir="index-basic" target="clean"/>
<ant dir="index-anchor" target="clean"/>
<ant dir="index-geoip" target="clean"/>
<ant dir="index-geoip" target="clean"/>
<ant dir="index-more" target="clean"/>
<ant dir="index-static" target="clean"/>
<ant dir="index-metadata" target="clean"/>
<ant dir="mimetype-filter" target="clean"/>
<ant dir="indexer-dummy" target="clean"/>
<ant dir="indexer-elastic" target="clean"/>
<ant dir="indexer-solr" target="clean"/>
Expand Down
28 changes: 28 additions & 0 deletions src/plugin/mimetype-filter/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF 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.
-->
<project name="mimetype-filter" default="jar-core">

<import file="../build-plugin.xml" />

<!-- for junit test -->
<mkdir dir="${build.test}/data"/>
<copy todir="${build.test}/data">
<fileset dir="sample" includes="**/*.txt"/>
</copy>

</project>
41 changes: 41 additions & 0 deletions src/plugin/mimetype-filter/ivy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" ?>

<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF 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.
-->

<ivy-module version="1.0">
<info organisation="org.apache.nutch" module="${ant.project.name}">
<license name="Apache 2.0"/>
<ivyauthor name="Apache Nutch Team" url="http://nutch.apache.org"/>
<description>
Apache Nutch
</description>
</info>

<configurations>
<include file="${nutch.root}/ivy/ivy-configurations.xml"/>
</configurations>

<publications>
<!--get the artifact from our module name-->
<artifact conf="master"/>
</publications>

<dependencies>
</dependencies>

</ivy-module>
37 changes: 37 additions & 0 deletions src/plugin/mimetype-filter/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF 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.
-->
<plugin
id="mimetype-filter"
name="Filter indexed documents by the detected MIME"
version="1.0.0"
provider-name="nutch.org">

<runtime>
<library name="mimetype-filter.jar">
<export name="*"/>
</library>
</runtime>

<extension id="org.apache.nutch.indexer.filter"
name="Nutch MIME filter"
point="org.apache.nutch.indexer.IndexingFilter">
<implementation id="MimeTypeIndexingFilter"
class="org.apache.nutch.indexer.filter.MimeTypeIndexingFilter"/>
</extension>

</plugin>
34 changes: 34 additions & 0 deletions src/plugin/mimetype-filter/sample/allow-images.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF 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.

# This filter can be configured to work in one of two modes (similar to
# suffix-url-filter)

# default to reject ('-'): in this mode, only documents with a mimetype that
# match the ones specified in the config file will be accepted, all other
# mimetypes will be rejected.

# default to accept ('+'): in this mode, only documents with a mimetype
# that match the ones specified in the config file will be rejected,
# all other mimetypes will be accepted.

# The format of this config file is one mimetype per line, with no preceding
# whitespace. Order, in which suffixes are specified, doesn't matter. Blank
# lines and comments (#) are allowed.
#

-

image
34 changes: 34 additions & 0 deletions src/plugin/mimetype-filter/sample/block-html.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF 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.

# This filter can be configured to work in one of two modes (similar to
# suffix-url-filter)

# default to reject ('-'): in this mode, only documents with a mimetype that
# match the ones specified in the config file will be accepted, all other
# mimetypes will be rejected.

# default to accept ('+'): in this mode, only documents with a mimetype
# that match the ones specified in the config file will be rejected,
# all other mimetypes will be accepted.

# The format of this config file is one mimetype per line, with no preceding
# whitespace. Order, in which suffixes are specified, doesn't matter. Blank
# lines and comments (#) are allowed.
#

+

text/html
Loading

0 comments on commit c059485

Please sign in to comment.