mirror of https://github.com/apache/lucene.git
LUCENE-3347: XML query parser did not always incorporate boosts from UserQuery elements
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1152525 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b2e6d30243
commit
347308b845
|
@ -102,6 +102,9 @@ Bug Fixes
|
|||
your string and encode/decode it using the default charset, it now uses
|
||||
a StringReader. Finally, MoreLikeThis's methods that take File, URL, InputStream,
|
||||
are deprecated, please create the Reader yourself. (Trejkaz, Robert Muir)
|
||||
|
||||
* LUCENE-3347: XML query parser did not always incorporate boosts from
|
||||
UserQuery elements. (Moogie, Uwe Schindler)
|
||||
|
||||
======================= Lucene 3.3.0 =======================
|
||||
|
||||
|
|
|
@ -74,7 +74,8 @@ public class UserInputQueryBuilder implements QueryBuilder {
|
|||
QueryParser parser=createQueryParser(fieldName, analyzer);
|
||||
q = parser.parse(text);
|
||||
}
|
||||
q.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
|
||||
// use the boost of the original query here, too and multiply (which may be != 1.0f):
|
||||
q.setBoost(q.getBoost()*DOMUtils.getAttribute(e,"boost",1.0f));
|
||||
return q;
|
||||
} catch (ParseException e1) {
|
||||
throw new ParserException(e1.getMessage());
|
||||
|
|
|
@ -121,6 +121,7 @@ public class TestParser extends LuceneTestCase {
|
|||
public void testCustomFieldUserQueryXML() throws ParserException, IOException
|
||||
{
|
||||
Query q=parse("UserInputQueryCustomField.xml");
|
||||
assertEquals(20.0f, q.getBoost());
|
||||
int h = searcher.search(q, null, 1000).totalHits;
|
||||
assertEquals("UserInputQueryCustomField should produce 0 result ", 0,h);
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<UserQuery fieldName="doesNotExist">Bank</UserQuery>
|
||||
<UserQuery fieldName="doesNotExist" boost="10">Bank^2</UserQuery>
|
||||
|
|
Loading…
Reference in New Issue