You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by ho...@apache.org on 2007/05/08 20:03:35 UTC
svn commit: r536278 - in /lucene/solr/trunk: CHANGES.txt
example/solr/conf/schema.xml src/java/org/apache/solr/schema/FieldType.java
src/test/org/apache/solr/BasicFunctionalityTest.java
src/test/test-files/solr/conf/schema.xml
Author: hossman
Date: Tue May 8 11:03:32 2007
New Revision: 536278
URL: http://svn.apache.org/viewvc?view=rev&rev=536278
Log:
SOLR-217 - no error if fields are unindexed and unstored, instead let them be quietly ignored
Modified:
lucene/solr/trunk/CHANGES.txt
lucene/solr/trunk/example/solr/conf/schema.xml
lucene/solr/trunk/src/java/org/apache/solr/schema/FieldType.java
lucene/solr/trunk/src/test/org/apache/solr/BasicFunctionalityTest.java
lucene/solr/trunk/src/test/test-files/solr/conf/schema.xml
Modified: lucene/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/CHANGES.txt?view=diff&rev=536278&r1=536277&r2=536278
==============================================================================
--- lucene/solr/trunk/CHANGES.txt (original)
+++ lucene/solr/trunk/CHANGES.txt Tue May 8 11:03:32 2007
@@ -167,7 +167,13 @@
descriptive error message. By default, the uniqueKey field is
a required field. This can be disabled by setting required=false
in schema.xml. (Greg Ludington via ryan)
-
+
+28. SOLR-217: Fields configured in the schema to be neither indexed or
+ stored will now be quietly ignored by Solr when Documents are added.
+ The example schema has a comment explaining how this can be used to
+ ignore any "unknown" fields.
+ (Will Johnson via hossman)
+
Changes in runtime behavior
1. Highlighting using DisMax will only pick up terms from the main
user query, not boost or filter queries (klaas).
Modified: lucene/solr/trunk/example/solr/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/example/solr/conf/schema.xml?view=diff&rev=536278&r1=536277&r2=536278
==============================================================================
--- lucene/solr/trunk/example/solr/conf/schema.xml (original)
+++ lucene/solr/trunk/example/solr/conf/schema.xml Tue May 8 11:03:32 2007
@@ -215,6 +215,11 @@
</analyzer>
</fieldType>
+ <!-- since fields of this type are by default not stored or indexed, any data added to
+ them will be ignored outright
+ -->
+ <fieldtype name="ignored" stored="false" indexed="false" class="solr.StrField" />
+
</types>
@@ -289,6 +294,13 @@
<dynamicField name="*_f" type="sfloat" indexed="true" stored="true"/>
<dynamicField name="*_d" type="sdouble" indexed="true" stored="true"/>
<dynamicField name="*_dt" type="date" indexed="true" stored="true"/>
+
+ <!-- uncomment the following to ignore any fields that don't already match an existing
+ field name or dynamic field, rather than reporting them as an error.
+ alternately, change the type="ignored" to some other type e.g. "text" if you want
+ unknown fields indexed and/or stored by default -->
+ <!--dynamicField name="*" type="ignored" /-->
+
</fields>
<!-- Field to use to determine and enforce document uniqueness.
Modified: lucene/solr/trunk/src/java/org/apache/solr/schema/FieldType.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/schema/FieldType.java?view=diff&rev=536278&r1=536277&r2=536278
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/schema/FieldType.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/schema/FieldType.java Tue May 8 11:03:32 2007
@@ -173,6 +173,11 @@
throw new SolrException(500, "Error while creating field '" + field + "' from value '" + externalVal + "'", e, false);
}
if (val==null) return null;
+ if (!field.indexed() && !field.stored()) {
+ log.finest("Ignoring unindexed/unstored field: " + field);
+ return null;
+ }
+
Field f = new Field(field.getName(),
val,
Modified: lucene/solr/trunk/src/test/org/apache/solr/BasicFunctionalityTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/BasicFunctionalityTest.java?view=diff&rev=536278&r1=536277&r2=536278
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/BasicFunctionalityTest.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/BasicFunctionalityTest.java Tue May 8 11:03:32 2007
@@ -55,6 +55,21 @@
super.tearDown();
}
+
+ public void testIgnoredFields() throws Exception {
+ lrf.args.put("version","2.0");
+ assertU("adding doc with ignored field",
+ adoc("id", "42", "foo_ignored", "blah blah"));
+ assertU("commit",
+ commit());
+
+ // :TODO: the behavior of querying on an unindexed field should be better specified in the future.
+ assertQ("query with ignored field",
+ req("bar_ignored:yo id:42")
+ ,"//*[@numFound='1']"
+ ,"//int[@name='id'][.='42']"
+ );
+ }
public void testSomeStuff() throws Exception {
lrf.args.put("version","2.0");
Modified: lucene/solr/trunk/src/test/test-files/solr/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/test-files/solr/conf/schema.xml?view=diff&rev=536278&r1=536277&r2=536278
==============================================================================
--- lucene/solr/trunk/src/test/test-files/solr/conf/schema.xml (original)
+++ lucene/solr/trunk/src/test/test-files/solr/conf/schema.xml Tue May 8 11:03:32 2007
@@ -406,7 +406,8 @@
<dynamicField name="*aa" type="string" indexed="true" stored="true"/>
<dynamicField name="*aaa" type="integer" indexed="false" stored="true"/>
-
+ <!-- ignored becuase not stored or indexed -->
+ <dynamicField name="*_ignored" type="text" indexed="false" stored="false"/>
</fields>