You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2012/07/30 19:13:17 UTC
svn commit: r1367180 - in /lucene/dev/branches/branch_4x: ./ dev-tools/
lucene/ lucene/analysis/
lucene/analysis/common/src/java/org/apache/lucene/analysis/path/
lucene/analysis/icu/src/java/org/apache/lucene/collation/ lucene/backwards/
lucene/benchma...
Author: hossman
Date: Mon Jul 30 17:13:15 2012
New Revision: 1367180
URL: http://svn.apache.org/viewvc?rev=1367180&view=rev
Log:
SOLR-3674: better docs, example, test for PathHierarchyTokenizerFactory (merge r1367178)
Added:
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/analysis/PathHierarchyTokenizerFactoryTest.java
- copied unchanged from r1367178, lucene/dev/trunk/solr/core/src/test/org/apache/solr/analysis/PathHierarchyTokenizerFactoryTest.java
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/dev-tools/ (props changed)
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/BUILD.txt (props changed)
lucene/dev/branches/branch_4x/lucene/CHANGES.txt (props changed)
lucene/dev/branches/branch_4x/lucene/JRE_VERSION_MIGRATION.txt (props changed)
lucene/dev/branches/branch_4x/lucene/LICENSE.txt (props changed)
lucene/dev/branches/branch_4x/lucene/MIGRATE.txt (props changed)
lucene/dev/branches/branch_4x/lucene/NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/lucene/README.txt (props changed)
lucene/dev/branches/branch_4x/lucene/analysis/ (props changed)
lucene/dev/branches/branch_4x/lucene/analysis/common/src/java/org/apache/lucene/analysis/path/PathHierarchyTokenizerFactory.java
lucene/dev/branches/branch_4x/lucene/analysis/icu/src/java/org/apache/lucene/collation/ICUCollationKeyFilterFactory.java (props changed)
lucene/dev/branches/branch_4x/lucene/backwards/ (props changed)
lucene/dev/branches/branch_4x/lucene/benchmark/ (props changed)
lucene/dev/branches/branch_4x/lucene/build.xml (props changed)
lucene/dev/branches/branch_4x/lucene/common-build.xml (props changed)
lucene/dev/branches/branch_4x/lucene/core/ (props changed)
lucene/dev/branches/branch_4x/lucene/demo/ (props changed)
lucene/dev/branches/branch_4x/lucene/facet/ (props changed)
lucene/dev/branches/branch_4x/lucene/grouping/ (props changed)
lucene/dev/branches/branch_4x/lucene/highlighter/ (props changed)
lucene/dev/branches/branch_4x/lucene/ivy-settings.xml (props changed)
lucene/dev/branches/branch_4x/lucene/join/ (props changed)
lucene/dev/branches/branch_4x/lucene/licenses/ (props changed)
lucene/dev/branches/branch_4x/lucene/memory/ (props changed)
lucene/dev/branches/branch_4x/lucene/misc/ (props changed)
lucene/dev/branches/branch_4x/lucene/module-build.xml (props changed)
lucene/dev/branches/branch_4x/lucene/queries/ (props changed)
lucene/dev/branches/branch_4x/lucene/queryparser/ (props changed)
lucene/dev/branches/branch_4x/lucene/sandbox/ (props changed)
lucene/dev/branches/branch_4x/lucene/site/ (props changed)
lucene/dev/branches/branch_4x/lucene/spatial/ (props changed)
lucene/dev/branches/branch_4x/lucene/suggest/ (props changed)
lucene/dev/branches/branch_4x/lucene/test-framework/ (props changed)
lucene/dev/branches/branch_4x/lucene/tools/ (props changed)
lucene/dev/branches/branch_4x/solr/ (props changed)
lucene/dev/branches/branch_4x/solr/CHANGES.txt (props changed)
lucene/dev/branches/branch_4x/solr/LICENSE.txt (props changed)
lucene/dev/branches/branch_4x/solr/NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/README.txt (props changed)
lucene/dev/branches/branch_4x/solr/build.xml (props changed)
lucene/dev/branches/branch_4x/solr/cloud-dev/ (props changed)
lucene/dev/branches/branch_4x/solr/common-build.xml (props changed)
lucene/dev/branches/branch_4x/solr/contrib/ (props changed)
lucene/dev/branches/branch_4x/solr/core/ (props changed)
lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema.xml
lucene/dev/branches/branch_4x/solr/dev-tools/ (props changed)
lucene/dev/branches/branch_4x/solr/example/ (props changed)
lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/schema.xml
lucene/dev/branches/branch_4x/solr/lib/ (props changed)
lucene/dev/branches/branch_4x/solr/licenses/ (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpclient-LICENSE-ASL.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpclient-NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpcore-LICENSE-ASL.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpcore-NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpmime-LICENSE-ASL.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpmime-NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/scripts/ (props changed)
lucene/dev/branches/branch_4x/solr/solrj/ (props changed)
lucene/dev/branches/branch_4x/solr/test-framework/ (props changed)
lucene/dev/branches/branch_4x/solr/testlogging.properties (props changed)
lucene/dev/branches/branch_4x/solr/webapp/ (props changed)
Modified: lucene/dev/branches/branch_4x/lucene/analysis/common/src/java/org/apache/lucene/analysis/path/PathHierarchyTokenizerFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/analysis/common/src/java/org/apache/lucene/analysis/path/PathHierarchyTokenizerFactory.java?rev=1367180&r1=1367179&r2=1367180&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/analysis/common/src/java/org/apache/lucene/analysis/path/PathHierarchyTokenizerFactory.java (original)
+++ lucene/dev/branches/branch_4x/lucene/analysis/common/src/java/org/apache/lucene/analysis/path/PathHierarchyTokenizerFactory.java Mon Jul 30 17:13:15 2012
@@ -27,13 +27,47 @@ import org.apache.lucene.analysis.util.T
/**
* Factory for {@link PathHierarchyTokenizer}.
+ * <p>
+ * This factory is typically configured for use only in the <code>index</code>
+ * Analyzer (or only in the <code>query</code> Analyzer, but never both).
+ * </p>
+ * <p>
+ * For example, in the configuration below a query for
+ * <code>Books/NonFic</code> will match documents indexed with values like
+ * <code>Books/NonFic</code>, <code>Books/NonFic/Law</code>,
+ * <code>Books/NonFic/Science/Physics</code>, etc. But it will not match
+ * documents indexed with values like <code>Books</code>, or
+ * <code>Books/Fic</code>...
+ * </p>
+ *
* <pre class="prettyprint" >
- * <fieldType name="text_path" class="solr.TextField" positionIncrementGap="100">
- * <analyzer>
- * <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="\" replace="/"/>
+ * <fieldType name="descendent_path" class="solr.TextField">
+ * <analyzer type="index">
+ * <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" />
* </analyzer>
- * </fieldType></pre>
- *
+ * <analyzer type="query">
+ * <tokenizer class="solr.KeywordTokenizerFactory" />
+ * </analyzer>
+ * </fieldType>
+ * </pre>
+ * <p>
+ * In this example however we see the oposite configuration, so that a query
+ * for <code>Books/NonFic/Science/Physics</code> would match documents
+ * containing <code>Books/NonFic</code>, <code>Books/NonFic/Science</code>,
+ * or <code>Books/NonFic/Science/Physics</code>, but not
+ * <code>Books/NonFic/Science/Physics/Theory</code> or
+ * <code>Books/NonFic/Law</code>.
+ * </p>
+ * <pre class="prettyprint" >
+ * <fieldType name="descendent_path" class="solr.TextField">
+ * <analyzer type="index">
+ * <tokenizer class="solr.KeywordTokenizerFactory" />
+ * </analyzer>
+ * <analyzer type="query">
+ * <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" />
+ * </analyzer>
+ * </fieldType>
+ * </pre>
*/
public class PathHierarchyTokenizerFactory extends TokenizerFactory {
Modified: lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema.xml?rev=1367180&r1=1367179&r2=1367180&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema.xml (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test-files/solr/collection1/conf/schema.xml Mon Jul 30 17:13:15 2012
@@ -414,7 +414,32 @@
<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
- </types>
+ <!--
+ Example of using PathHierarchyTokenizerFactory at index time, so
+ queries for paths match documents at that path, or in descendent paths
+ -->
+ <fieldType name="path" class="solr.TextField">
+ <analyzer type="index">
+ <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" />
+ </analyzer>
+ <analyzer type="query">
+ <tokenizer class="solr.KeywordTokenizerFactory" />
+ </analyzer>
+ </fieldType>
+ <!--
+ Example of using PathHierarchyTokenizerFactory at query time, so
+ queries for paths match documents at that path, or in ancestor paths
+ -->
+ <fieldType name="ancestor_path" class="solr.TextField">
+ <analyzer type="index">
+ <tokenizer class="solr.KeywordTokenizerFactory" />
+ </analyzer>
+ <analyzer type="query">
+ <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" />
+ </analyzer>
+ </fieldType>
+
+</types>
<fields>
@@ -640,6 +665,10 @@
<!-- Type used to index the lat and lon components for the "location" FieldType -->
<dynamicField name="*_coordinate" type="tdouble" indexed="true" stored="false" omitNorms="true" />
+
+ <dynamicField name="*_path" type="path" indexed="true" stored="true" omitNorms="true" multiValued="true" />
+ <dynamicField name="*_ancestor" type="ancestor_path" indexed="true" stored="true" omitNorms="true" multiValued="true" />
+
</fields>
<defaultSearchField>text</defaultSearchField>
@@ -673,6 +702,7 @@
<!-- dynamic destination -->
<copyField source="*_dynamic" dest="dynamic_*"/>
+ <copyField source="*_path" dest="*_ancestor"/>
<!-- example of a custom similarity -->
<similarity class="solr.CustomSimilarityFactory">
Modified: lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/schema.xml?rev=1367180&r1=1367179&r2=1367180&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/schema.xml (original)
+++ lucene/dev/branches/branch_4x/solr/example/solr/collection1/conf/schema.xml Mon Jul 30 17:13:15 2012
@@ -137,7 +137,6 @@
<field name="payloads" type="payloads" indexed="true" stored="true"/>
-
<field name="_version_" type="long" indexed="true" stored="true"/>
<!-- Uncommenting the following will create a "timestamp" field using
@@ -607,12 +606,30 @@
</analyzer>
</fieldType>
- <fieldType name="text_path" class="solr.TextField" positionIncrementGap="100">
- <analyzer>
- <tokenizer class="solr.PathHierarchyTokenizerFactory"/>
+ <!--
+ Example of using PathHierarchyTokenizerFactory at index time, so
+ queries for paths match documents at that path, or in descendent paths
+ -->
+ <fieldType name="descendent_path" class="solr.TextField">
+ <analyzer type="index">
+ <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" />
+ </analyzer>
+ <analyzer type="query">
+ <tokenizer class="solr.KeywordTokenizerFactory" />
+ </analyzer>
+ </fieldType>
+ <!--
+ Example of using PathHierarchyTokenizerFactory at query time, so
+ queries for paths match documents at that path, or in ancestor paths
+ -->
+ <fieldType name="ancestor_path" class="solr.TextField">
+ <analyzer type="index">
+ <tokenizer class="solr.KeywordTokenizerFactory" />
+ </analyzer>
+ <analyzer type="query">
+ <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" />
</analyzer>
</fieldType>
-
<!-- since fields of this type are by default not stored or indexed,
any data added to them will be ignored outright. -->
@@ -1041,6 +1058,7 @@
<filter class="solr.SnowballPorterFilterFactory" language="Turkish"/>
</analyzer>
</fieldType>
+
</types>
<!-- Similarity is the scoring routine for each document vs. a query.