SOLR-1339: fix dismax to handle parse exceptions, change types in tests to use new numeric types

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@801786 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2009-08-06 19:30:40 +00:00
parent b33318f06e
commit ce84cfc655
7 changed files with 114 additions and 67 deletions

View File

@ -359,6 +359,7 @@
<field name="features" type="text" indexed="true" stored="true" multiValued="true" termVectors="true" termPositions="true" termOffsets="true"/>
<field name="includes" type="text" indexed="true" stored="true"/>
<field name="weight" type="float" indexed="true" stored="true"/>
<field name="price" type="float" indexed="true" stored="true"/>
<!-- "default" values can be specified for fields, indicating which
@ -367,6 +368,9 @@
<field name="popularity" type="int" indexed="true" stored="true"/>
<field name="inStock" type="boolean" indexed="true" stored="true"/>
<field name="title" type="text" indexed="true" stored="true"/>
<!-- Some sample docs exists solely to demonstrate the spellchecker
functionality, this is the only field they contain.
Typically you might build the spellchecker off "catchall" type field
@ -409,6 +413,13 @@
<dynamicField name="*_d" type="double" indexed="true" stored="true"/>
<dynamicField name="*_dt" type="date" indexed="true" stored="true"/>
<!-- some trie-coded dynamic fields for faster range queries -->
<dynamicField name="*_ti" type="tint" indexed="true" stored="true"/>
<dynamicField name="*_tl" type="tlong" indexed="true" stored="true"/>
<dynamicField name="*_tf" type="tfloat" indexed="true" stored="true"/>
<dynamicField name="*_td" type="tdouble" indexed="true" stored="true"/>
<dynamicField name="*_tdt" type="tdate" indexed="true" stored="true"/>
<dynamicField name="*_pi" type="pint" indexed="true" stored="true"/>
<dynamicField name="ignored_*" type="ignored" multiValued="true"/>

View File

@ -218,16 +218,24 @@ public class DocumentAnalysisRequestHandler extends AnalysisRequestHandlerBase {
Set<String> termsToMatch = new HashSet<String>();
if (request.getQuery() != null && request.isShowMatch()) {
List<Token> tokens = analyzeValue(request.getQuery(), fieldType.getQueryAnalyzer());
for (Token token : tokens) {
termsToMatch.add(token.term());
try {
List<Token> tokens = analyzeValue(request.getQuery(), fieldType.getQueryAnalyzer());
for (Token token : tokens) {
termsToMatch.add(token.term());
}
} catch (Exception e) {
// ignore analysis exceptions since we are applying arbitrary text to all fields
}
}
if (request.getQuery() != null) {
AnalysisContext analysisContext = new AnalysisContext(fieldType, fieldType.getQueryAnalyzer(), Collections.EMPTY_SET);
NamedList<List<NamedList>> tokens = analyzeValue(request.getQuery(), analysisContext);
fieldTokens.add("query", tokens);
try {
AnalysisContext analysisContext = new AnalysisContext(fieldType, fieldType.getQueryAnalyzer(), Collections.EMPTY_SET);
NamedList<List<NamedList>> tokens = analyzeValue(request.getQuery(), analysisContext);
fieldTokens.add("query", tokens);
} catch (Exception e) {
// ignore analysis exceptions since we are applying arbitrary text to all fields
}
}
Analyzer analyzer = fieldType.getAnalyzer();

View File

@ -777,7 +777,7 @@ public class SolrPluginUtils {
DisjunctionMaxQuery q = new DisjunctionMaxQuery(a.tie);
/* we might not get any valid queries from delegation,
* in which we should return null
* in which case we should return null
*/
boolean ok = false;
@ -795,7 +795,11 @@ public class SolrPluginUtils {
return ok ? q : null;
} else {
return super.getFieldQuery(field, queryText);
try {
return super.getFieldQuery(field, queryText);
} catch (Exception e) {
return null;
}
}
}

View File

@ -591,47 +591,47 @@ public class ConvertedLegacyTest extends AbstractSolrTestCase {
// test binary float ranges and sorting
assertU("<delete><id>44</id></delete>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">1.4142135</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">Infinity</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">-Infinity</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">NaN</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">2</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">-1</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">-987654321</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">-999999.99</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">-1e20</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">0</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">1.4142135</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">Infinity</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">-Infinity</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">NaN</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">2</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">-1</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">-987654321</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">-999999.99</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">-1e20</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sf\">0</field></doc></add>");
assertU("<commit/>");
assertQ(req("id:44")
,"*[count(//doc)=10]"
);
assertQ(req("num_f:Infinity")
assertQ(req("num_sf:Infinity")
,"//@numFound[.='1'] "
,"//float[.='Infinity']"
);
assertQ(req("num_f:\"-Infinity\"")
assertQ(req("num_sf:\"-Infinity\"")
,"//@numFound[.='1'] "
,"//float[.='-Infinity']"
);
assertQ(req("num_f:\"NaN\"")
assertQ(req("num_sf:\"NaN\"")
,"//@numFound[.='1'] "
,"//float[.='NaN']"
);
assertQ(req("num_f:\"-1e20\"")
assertQ(req("num_sf:\"-1e20\"")
,"//@numFound[.='1']"
);
assertQ(req("id:44;num_f asc;")
assertQ(req("id:44;num_sf asc;")
,"//doc[1]/float[.='-Infinity'] "
,"//doc[last()]/float[.='NaN']"
);
assertQ(req("id:44;num_f desc;")
assertQ(req("id:44;num_sf desc;")
,"//doc[1]/float[.='NaN'] "
,"//doc[last()]/float[.='-Infinity']"
);
assertQ(req("num_f:[-1 TO 2]")
assertQ(req("num_sf:[-1 TO 2]")
,"*[count(//doc)=4]"
);
assertQ(req("num_f:[-Infinity TO Infinity]")
assertQ(req("num_sf:[-Infinity TO Infinity]")
,"*[count(//doc)=9]"
);
@ -640,50 +640,50 @@ public class ConvertedLegacyTest extends AbstractSolrTestCase {
// test binary double ranges and sorting
assertU("<delete><id>44</id></delete>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">1.4142135</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">Infinity</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">-Infinity</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">NaN</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">2</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">-1</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">1e-100</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">-999999.99</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">-1e100</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">0</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">1.4142135</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">Infinity</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">-Infinity</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">NaN</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">2</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">-1</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">1e-100</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">-999999.99</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">-1e100</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_sd\">0</field></doc></add>");
assertU("<commit/>");
assertQ(req("id:44")
,"*[count(//doc)=10]"
);
assertQ(req("num_d:Infinity")
assertQ(req("num_sd:Infinity")
,"//@numFound[.='1'] "
,"//double[.='Infinity']"
);
assertQ(req("num_d:\"-Infinity\"")
assertQ(req("num_sd:\"-Infinity\"")
,"//@numFound[.='1'] "
,"//double[.='-Infinity']"
);
assertQ(req("num_d:\"NaN\"")
assertQ(req("num_sd:\"NaN\"")
,"//@numFound[.='1'] "
,"//double[.='NaN']"
);
assertQ(req("num_d:\"-1e100\"")
assertQ(req("num_sd:\"-1e100\"")
,"//@numFound[.='1']"
);
assertQ(req("num_d:\"1e-100\"")
assertQ(req("num_sd:\"1e-100\"")
,"//@numFound[.='1']"
);
assertQ(req("id:44;num_d asc;")
assertQ(req("id:44;num_sd asc;")
,"//doc[1]/double[.='-Infinity'] "
,"//doc[last()]/double[.='NaN']"
);
assertQ(req("id:44;num_d desc;")
assertQ(req("id:44;num_sd desc;")
,"//doc[1]/double[.='NaN'] "
,"//doc[last()]/double[.='-Infinity']"
);
assertQ(req("num_d:[-1 TO 2]")
assertQ(req("num_sd:[-1 TO 2]")
,"*[count(//doc)=5]"
);
assertQ(req("num_d:[-Infinity TO Infinity]")
assertQ(req("num_sd:[-Infinity TO Infinity]")
,"*[count(//doc)=9]"
);
@ -736,32 +736,32 @@ public class ConvertedLegacyTest extends AbstractSolrTestCase {
assertU("<delete><query>id_i:[1000 TO 1010]</query></delete>");
assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1000</field><field name=\"a_i\">1</field><field name=\"nullfirst\">Z</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1001</field><field name=\"a_i\">10</field><field name=\"nullfirst\">A</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1002</field><field name=\"a_i\">1</field><field name=\"b_i\">100</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1002</field><field name=\"a_i\">1</field><field name=\"b_si\">100</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1003</field><field name=\"a_i\">-1</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1004</field><field name=\"a_i\">15</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1005</field><field name=\"a_i\">1</field><field name=\"b_i\">50</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1005</field><field name=\"a_i\">1</field><field name=\"b_si\">50</field></doc></add>");
assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1006</field><field name=\"a_i\">0</field></doc></add>");
assertU("<commit/>");
assertQ(req("id_i:[1000 TO 1010]")
,"*[count(//doc)=7]"
);
assertQ(req("id_i:[1000 TO 1010]; b_i asc")
assertQ(req("id_i:[1000 TO 1010]; b_si asc")
,"*[count(//doc)=7] "
,"//doc[1]/int[.='50'] "
,"//doc[2]/int[.='100']"
);
assertQ(req("id_i:[1000 TO 1010]; b_i desc")
assertQ(req("id_i:[1000 TO 1010]; b_si desc")
,"*[count(//doc)=7] "
,"//doc[1]/int[.='100'] "
,"//doc[2]/int[.='50']"
);
assertQ(req("id_i:[1000 TO 1010]; a_i asc,b_i desc")
assertQ(req("id_i:[1000 TO 1010]; a_i asc,b_si desc")
,"*[count(//doc)=7] "
,"//doc[3]/int[.='100'] "
,"//doc[4]/int[.='50'] "
,"//doc[5]/int[.='1000']"
);
assertQ(req("id_i:[1000 TO 1010]; a_i asc,b_i asc")
assertQ(req("id_i:[1000 TO 1010]; a_i asc,b_si asc")
,"*[count(//doc)=7] "
,"//doc[3]/int[.='50'] "
,"//doc[4]/int[.='100'] "

View File

@ -146,7 +146,7 @@ public class DisMaxRequestHandlerTest extends AbstractSolrTestCase {
assertQ("explicit ALTQ",
req( "qt", "dismax",
"q.alt", "id:blahbalh",
"q.alt", "id:9999",
"fq", "id:666",
"facet", "false" )
,"//*[@numFound='0']"

View File

@ -57,7 +57,7 @@ public class TestDistributedSearch extends TestCase {
String id="id";
String t1="a_t";
String i1="a_i";
String i1="a_si";
String tlong = "tlong";
String oddField="oddField_s";
String missingField="missing_but_valid_field_t";

View File

@ -42,10 +42,20 @@
These are provided more for backward compatability, allowing one
to create a schema that matches an existing lucene index.
-->
<fieldType name="integer" class="solr.IntField"/>
<fieldType name="long" class="solr.LongField"/>
<fieldtype name="float" class="solr.FloatField"/>
<fieldType name="double" class="solr.DoubleField"/>
<fieldType name="pint" class="solr.IntField"/>
<fieldType name="plong" class="solr.LongField"/>
<fieldtype name="pfloat" class="solr.FloatField"/>
<fieldType name="pdouble" class="solr.DoubleField"/>
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="tint" class="solr.TrieIntField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
<!-- numeric field types that manipulate the value into
a string value that isn't human readable in it's internal form,
@ -110,6 +120,9 @@
seconds part (.999) is optional.
-->
<fieldtype name="date" class="solr.DateField" sortMissingLast="true"/>
<fieldtype name="tdate" class="solr.TrieDateField" sortMissingLast="true" precisionStep="6"/>
<fieldtype name="pdate" class="solr.DateField" sortMissingLast="true"/>
<!-- solr.TextField allows the specification of custom
text analyzers specified as a tokenizer and a list
@ -343,12 +356,11 @@
<fieldType name="uuid" class="solr.UUIDField" />
<fieldType name="tlong" class="solr.TrieField" type="long" omitNorms="true" positionIncrementGap="0" indexed="true" stored="false" />
</types>
<fields>
<field name="id" type="integer" indexed="true" stored="true" multiValued="false" required="false"/>
<field name="id" type="int" indexed="true" stored="true" multiValued="false" required="false"/>
<field name="signatureField" type="string" indexed="true" stored="false"/>
<field name="uuid" type="uuid" stored="true" />
<field name="name" type="nametext" indexed="true" stored="true"/>
@ -373,8 +385,8 @@
<field name="bind" type="boolean" indexed="true" stored="false"/>
<field name="bsto" type="boolean" indexed="false" stored="true"/>
<field name="bindsto" type="boolean" indexed="true" stored="true"/>
<field name="isto" type="integer" indexed="false" stored="true"/>
<field name="iind" type="integer" indexed="true" stored="false"/>
<field name="isto" type="int" indexed="false" stored="true"/>
<field name="iind" type="int" indexed="true" stored="false"/>
<field name="ssto" type="string" indexed="false" stored="true"/>
<field name="sind" type="string" indexed="true" stored="false"/>
<field name="sindsto" type="string" indexed="true" stored="true"/>
@ -429,7 +441,7 @@
<field name="timestamp" type="date" indexed="true" stored="true" default="NOW" multiValued="false"/>
<field name="multiDefault" type="string" indexed="true" stored="true" default="muLti-Default" multiValued="true"/>
<field name="intDefault" type="sint" indexed="true" stored="true" default="42" multiValued="false"/>
<field name="intDefault" type="int" indexed="true" stored="true" default="42" multiValued="false"/>
<field name="tlong" type="tlong" indexed="true" stored="true" />
@ -442,17 +454,29 @@
Longer patterns will be matched first. if equal size patterns
both match, the first appearing in the schema will be used.
-->
<dynamicField name="*_i" type="sint" indexed="true" stored="true"/>
<dynamicField name="*_i" type="int" indexed="true" stored="true"/>
<dynamicField name="*_s" type="string" indexed="true" stored="true"/>
<dynamicField name="*_s1" type="string" indexed="true" stored="true" multiValued="false"/>
<dynamicField name="*_l" type="slong" indexed="true" stored="true"/>
<dynamicField name="*_l" type="long" indexed="true" stored="true"/>
<dynamicField name="*_t" type="text" indexed="true" stored="true"/>
<dynamicField name="*_b" type="boolean" indexed="true" stored="true"/>
<dynamicField name="*_f" type="sfloat" indexed="true" stored="true"/>
<dynamicField name="*_d" type="sdouble" indexed="true" stored="true"/>
<dynamicField name="*_f" type="float" indexed="true" stored="true"/>
<dynamicField name="*_d" type="double" indexed="true" stored="true"/>
<dynamicField name="*_dt" type="date" indexed="true" stored="true"/>
<dynamicField name="*_bcd" type="bcdstr" indexed="true" stored="true"/>
<dynamicField name="*_si" type="sint" indexed="true" stored="true"/>
<dynamicField name="*_sl" type="slong" indexed="true" stored="true"/>
<dynamicField name="*_sf" type="sfloat" indexed="true" stored="true"/>
<dynamicField name="*_sd" type="sdouble" indexed="true" stored="true"/>
<dynamicField name="*_pi" type="pint" indexed="true" stored="true"/>
<dynamicField name="*_pf" type="pfloat" indexed="true" stored="true"/>
<dynamicField name="*_pl" type="plong" indexed="true" stored="true"/>
<dynamicField name="*_pd" type="pdouble" indexed="true" stored="true"/>
<dynamicField name="*_pdt" type="pdate" indexed="true" stored="true"/>
<dynamicField name="*_sI" type="string" indexed="true" stored="false"/>
<dynamicField name="*_sS" type="string" indexed="false" stored="true"/>
<dynamicField name="t_*" type="text" indexed="true" stored="true"/>
@ -467,7 +491,7 @@
<!-- for testing to ensure that longer patterns are matched first -->
<dynamicField name="*aa" type="string" indexed="true" stored="true"/>
<dynamicField name="*aaa" type="integer" indexed="false" stored="true"/>
<dynamicField name="*aaa" type="pint" indexed="false" stored="true"/>
<!-- ignored becuase not stored or indexed -->
<dynamicField name="*_ignored" type="text" indexed="false" stored="false"/>