lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Muir <rcm...@gmail.com>
Subject Re: svn commit: r1091516 - in /lucene/dev/trunk/solr: CHANGES.txt src/java/org/apache/solr/search/ValueSourceParser.java src/test/org/apache/solr/search/function/TestFunctionQuery.java
Date Thu, 14 Apr 2011 16:56:37 GMT
I think this is causing tests to consistently fail (at least on
windows). I opened a JIRA issue:
https://issues.apache.org/jira/browse/SOLR-2468

I set the test to @ignore for now

On Tue, Apr 12, 2011 at 1:40 PM,  <hossman@apache.org> wrote:
> Author: hossman
> Date: Tue Apr 12 17:40:22 2011
> New Revision: 1091516
>
> URL: http://svn.apache.org/viewvc?rev=1091516&view=rev
> Log:
> SOLR-2335: New field(...) function syntax for refering to complex field names (containing
whitespace or special characters)
>
> Modified:
>    lucene/dev/trunk/solr/CHANGES.txt
>    lucene/dev/trunk/solr/src/java/org/apache/solr/search/ValueSourceParser.java
>    lucene/dev/trunk/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java
>
> Modified: lucene/dev/trunk/solr/CHANGES.txt
> URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1091516&r1=1091515&r2=1091516&view=diff
> ==============================================================================
> --- lucene/dev/trunk/solr/CHANGES.txt (original)
> +++ lucene/dev/trunk/solr/CHANGES.txt Tue Apr 12 17:40:22 2011
> @@ -121,6 +121,8 @@ New Features
>  * SOLR-2338: Add support for using <similarity/> in a schema's fieldType,
>   for customizing scoring on a per-field basis. (hossman, yonik, rmuir)
>
> +* SOLR-2335: New 'field("...")' function syntax for refering to complex
> +  field names (containing whitespace or special characters) in functions.
>
>  Optimizations
>  ----------------------
>
> Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/search/ValueSourceParser.java
> URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/search/ValueSourceParser.java?rev=1091516&r1=1091515&r2=1091516&view=diff
> ==============================================================================
> --- lucene/dev/trunk/solr/src/java/org/apache/solr/search/ValueSourceParser.java (original)
> +++ lucene/dev/trunk/solr/src/java/org/apache/solr/search/ValueSourceParser.java Tue
Apr 12 17:40:22 2011
> @@ -335,6 +335,15 @@ public abstract class ValueSourceParser
>         return new StringDistanceFunction(str1, str2, dist);
>       }
>     });
> +    addParser("field", new ValueSourceParser() {
> +      @Override
> +      public ValueSource parse(FunctionQParser fp) throws ParseException {
> +
> +        String fieldName = fp.parseArg();
> +        SchemaField f = fp.getReq().getSchema().getField(fieldName);
> +        return f.getType().getValueSource(f, fp);
> +      }
> +    });
>
>     addParser(new DoubleParser("rad") {
>       @Override
>
> Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java
> URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java?rev=1091516&r1=1091515&r2=1091516&view=diff
> ==============================================================================
> --- lucene/dev/trunk/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java
(original)
> +++ lucene/dev/trunk/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java
Tue Apr 12 17:40:22 2011
> @@ -71,16 +71,14 @@ public class TestFunctionQuery extends S
>
>   // replace \0 with the field name and create a parseable string
>   public String func(String field, String template) {
> -    StringBuilder sb = new StringBuilder("_val_:\"");
> +    StringBuilder sb = new StringBuilder("{!func}");
>     for (char ch : template.toCharArray()) {
>       if (ch=='\0') {
>         sb.append(field);
>         continue;
>       }
> -      if (ch=='"') sb.append('\\');
>       sb.append(ch);
>     }
> -    sb.append('"');
>     return sb.toString();
>   }
>
> @@ -520,5 +518,38 @@ public class TestFunctionQuery extends S
>     dofunc("atan2(.25,.5)", Math.atan2(.25,.5));
>   }
>
> +  /**
> +   * verify that both the field("...") value source parser as well as
> +   * ExternalFileField work with esoteric field names
> +   */
> +  @Test
> +  public void testExternalFieldValueSourceParser() {
> +
> +    String field = "CoMpleX \" fieldName _extf";
> +    String fieldAsFunc = "field(\"CoMpleX \\\" fieldName _extf\")";
> +
> +    float[] ids = {100,-4,0,10,25,5,77,23,55,-78,-45,-24,63,78,94,22,34,54321,261,-627};
> +
> +    createIndex(null,ids);
> +
> +    // Unsorted field, largest first
> +    makeExternalFile(field, "54321=543210\n0=-999\n25=250","UTF-8");
> +    // test identity (straight field value)
> +    singleTest(fieldAsFunc, "\0", 54321, 543210, 0,-999, 25,250, 100, 1);
> +    Object orig = FileFloatSource.onlyForTesting;
> +    singleTest(fieldAsFunc, "log(\0)");
> +    // make sure the values were cached
> +    assertTrue(orig == FileFloatSource.onlyForTesting);
> +    singleTest(fieldAsFunc, "sqrt(\0)");
> +    assertTrue(orig == FileFloatSource.onlyForTesting);
> +
> +    makeExternalFile(fieldAsFunc, "0=1","UTF-8");
> +    assertU(adoc("id", "10000")); // will get same reader if no index change
> +    assertU(commit());
> +    singleTest(fieldAsFunc, "sqrt(\0)");
> +    assertTrue(orig != FileFloatSource.onlyForTesting);
> +
> +    purgeFieldCache(FieldCache.DEFAULT);   // avoid FC insanity
> +  }
>
>  }
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message