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:
Uwe Schindler 2011-07-30 22:06:16 +00:00
parent b2e6d30243
commit 347308b845
4 changed files with 7 additions and 2 deletions

View File

@ -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 =======================

View File

@ -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());

View File

@ -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);
}

View File

@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<UserQuery fieldName="doesNotExist">Bank</UserQuery>
<UserQuery fieldName="doesNotExist" boost="10">Bank^2</UserQuery>