Skip to content

Commit

Permalink
Made the query params that support better scoring default
Browse files Browse the repository at this point in the history
  • Loading branch information
romanchyla committed Aug 28, 2019
1 parent d8e3e05 commit 8667bf6
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -764,12 +764,15 @@ public Query parse(FunctionQParser fp) throws SyntaxError {

LuceneCacheWrapper<NumericDocValues> boostWrapper = getLuceneCache(fp, "cite_read_boost");

SecondOrderQuery outerQuery = new SecondOrderQuery( // references
SecondOrderQuery outerQuery =
new SecondOrderQuery( // references
new SecondOrderQuery( // topn
new SecondOrderQuery(innerQuery, // classic_relevance
new SecondOrderCollectorAdsClassicScoringFormula(referencesWrapper, boostWrapper)),
//new SecondOrderQuery(innerQuery, // classic_relevance
// new SecondOrderCollectorAdsClassicScoringFormula(referencesWrapper, boostWrapper)),
innerQuery,
new SecondOrderCollectorTopN(200)),
new SecondOrderCollectorCitesRAM(referencesWrapper));

outerQuery.getcollector().setFinalValueType(FinalValueType.ABS_COUNT_NORM);
return outerQuery;
};
Expand Down Expand Up @@ -841,12 +844,15 @@ public Query parse(FunctionQParser fp) throws SyntaxError {

LuceneCacheWrapper<NumericDocValues> boostWrapper = getLuceneCache(fp, "cite_read_boost");

SecondOrderQuery outerQuery = new SecondOrderQuery( // citations
SecondOrderQuery outerQuery =
new SecondOrderQuery( // citations
new SecondOrderQuery( // topn
new SecondOrderQuery(innerQuery, // classic_relevance
new SecondOrderCollectorAdsClassicScoringFormula(citationsWrapper, boostWrapper)),
innerQuery,
//new SecondOrderQuery(innerQuery, // classic_relevance
// new SecondOrderCollectorAdsClassicScoringFormula(citationsWrapper, boostWrapper)),
new SecondOrderCollectorTopN(200)),
new SecondOrderCollectorCitedBy(citationsWrapper));

outerQuery.getcollector().setFinalValueType(FinalValueType.ABS_COUNT);
return outerQuery;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
}

Map<String, Float> statFields = getStaticFields();
if (statFields.containsKey(field)) {
if (statFields.containsKey(field) && node.getParent() != null && !(node.getParent() instanceof TermRangeQueryNode)) {
node = new AqpConstantQueryNode(node);
Float boost = statFields.get(field);
if (boost != null && boost != 1.0f) {
Expand Down
5 changes: 4 additions & 1 deletion contrib/adsabs/src/test/org/adsabs/TestAdsAllFields.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,19 +410,22 @@ public void test() throws Exception {
*/
assertQ(req("q", "author:\"Einstein, A\"",
"aqp.constant_scoring", "author^13 title^12",
"aqp.classic_scoring.modifier", "0.48",
"fl", "recid,score"),
"//*[@numFound='1']",
"//doc/int[@name='recid'][.='100']",
"//doc/float[@name='score'][.='13.0']"
"//doc/float[@name='score'][.='13.0']" // 13.00 * (cite_read_boost + aqp.classic_scoring.modifier)
);
assertQ(req("q", "author:\"Einstein, A\" AND author:\"Anders\"",
"aqp.constant_scoring", "author^13",
"aqp.classic_scoring.modifier", "0.48",
"fl", "recid,score"),
"//*[@numFound='1']",
"//doc/int[@name='recid'][.='100']",
"//doc/float[@name='score'][.='26.0']");
assertQ(req("q", "author:\"Einstein, A\" OR author:\"Anders\"",
"aqp.constant_scoring", "author^13",
"aqp.classic_scoring.modifier", "0.48",
"fl", "recid,score"),
"//*[@numFound='1']",
"//doc/int[@name='recid'][.='100']",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1222,12 +1222,16 @@ public void testOtherCases() throws Exception {
assertQ(req("q", "title:\"GBT Survey of 50 Faint Fermi\"~2"),
"//*[@numFound>='4']");

assertQ(req("q", "title:\"A 350-MHz GBT Survey of 50 Faint Fermi γ-ray Sources for Radio Millisecond Pulsars\""),

assertQ(req("q", "title:\"A 350-MHz GBT Survey of 50 Faint Fermi γ-ray Sources for Radio Millisecond Pulsars\"",
"indent", "true",
"debugQuery", "true"),
"//*[@numFound='4']",
"//doc/str[@name='id'][.='400']",
"//doc/str[@name='id'][.='401']",
"//doc/str[@name='id'][.='402']",
"//doc/str[@name='id'][.='403']");
"//doc/str[@name='id'][.='403']"
);
assertQ(req("q", "title:\"A 350-MHz GBT Survey of 50 Faint Fermi γ ray Sources for Radio Millisecond Pulsars\""),
"//*[@numFound='4']",
"//doc/str[@name='id'][.='400']",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public void tearDown() throws Exception {

public void testUnfieldedSearch() throws Exception {


// have constant scoring work even for unfielded searches
assertQueryEquals(req("defType", "aqp", "q", "foo bar",
"qf", "bibcode^5 title^10",
Expand Down Expand Up @@ -375,6 +376,9 @@ public void testSpecialCases() throws Exception {
"title", "title bitle"));
assertU(commit("waitSearcher", "true"));

assertQ(req("q", "similar(foo bar baz title bitle, input abstract title, 100, 100, 1, 1)"),
"//*[@numFound='1']",
"//doc/str[@name='id'][.='2']");

// similar()
assertQueryEquals(req("defType", "aqp", "q", "similar(foo bar baz, input)"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,23 @@
Modified qf
original: first_author^3.0 author^2 title^1.4 abstract^1.3 keyword^1.4 keyword_norm^1.4 all body^0.1 year
new: first_author^5 author^2 title^1.5 abstract^1.3 identifier^1 bibstem^1 year^2
August 28, 2019
Modified qf:
old: first_author^5 author^2 title^1.5 abstract^1.3 identifier^1 bibstem^1 year^2
new: first_author^0.9 author^0.85 year^0.8 title^0.8 abstract^0.7 identifier^0.8 bibstem^0.8 keyword^0.8
-->
<str name="qf">first_author^5 author^2 title^1.5 abstract^1.3 identifier^1 bibstem^1 year^2</str>
<str name="qf">first_author^0.9 author^0.85 year^0.8 title^0.8 abstract^0.7 identifier^0.8 bibstem^0.8 keyword^0.8</str>

<str name="defType">aqp</str>
<str name="aqp.unfielded.tokens.strategy">disjuncts</str>
<str name="aqp.unfielded.tokens.new.type">simple</str>
<str name="aqp.unfielded.ignore.fields">entdate pubdate year</str>
<str name="aqp.unfielded.tokens.function.name">edismax_combined_aqp</str>
<str name="useFastVectorHighlighter">true</str>
<str name="aqp.classic_scoring.modifier">0.5</str>
<str name="aqp.constant_scoring">first_author^14 author^13 year^10 bibstem^10</str>
<str name="aqp.multiphrase.keep_one">SYNONYM</str>
</lst>
<lst name="invariants">
<str name="echoParams">explicit</str>
Expand All @@ -349,6 +358,9 @@
<str name="aqp.unfielded.ignore.fields">entdate pubdate year</str>
<str name="aqp.unfielded.tokens.function.name">edismax_combined_aqp</str>
<str name="useFastVectorHighlighter">true</str>
<str name="aqp.classic_scoring.modifier">0.5</str>
<str name="aqp.constant_scoring">first_author^14 author^13 year^10 bibstem^10</str>
<str name="aqp.multiphrase.keep_one">SYNONYM</str>
</lst>
<lst name="invariants">
<str name="echoParams">explicit</str>
Expand Down Expand Up @@ -697,7 +709,7 @@
<str name="aqp.floatFields">cite_read_boost,citation_count_norm</str>
<str name="aqp.intFields">recid,pubdate_sort,citation_count,classic_factor,simbid,read_count,author_count,page_count,data_count</str>
<str name="aqp.authorFields">author,first_author,book_author,editor</str>
<str name="aqp.humanized.dates">pubdate:date,entdate:entry_date</str>
<str name="aqp.humanized.dates">pubdate:date,entdate:entry_date:timestamp</str>
<str name="aqp.force.fuzzy.phrases">author,first_author,book_author,editor</str>
</lst>
</queryParser>
Expand Down

0 comments on commit 8667bf6

Please sign in to comment.