Skip to content

Commit

Permalink
Fixed a bug in the function query parser; was not resetting position …
Browse files Browse the repository at this point in the history
…when reading multiple strings
  • Loading branch information
romanchyla committed Feb 14, 2020
1 parent 7949997 commit 3b23d3c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,9 @@ public AqpFunctionQueryBuilder getBuilder(String funcName, QueryNode node, Query
}
AqpFunctionQParser parser = new AqpFunctionQParser("", localParams,
reqAttr.getParams(), req);

// TODO: builder is reusing parser object; that may be bad if two threads
// are accessing it. Not happening now, but ...
return new AqpSubQueryTreeBuilder(provider, parser);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @see AnalyzerQueryNodeProcessor
*
*/
public class AqpUnfieldedSearchProcessor extends QueryNodeProcessorImpl implements
public class AqpUnfieldedSearchProcessor extends AqpQueryNodeProcessorImpl implements
QueryNodeProcessor {

ADSEscapeQuerySyntaxImpl escaper = new ADSEscapeQuerySyntaxImpl();
Expand Down Expand Up @@ -102,6 +102,9 @@ protected QueryNode postProcessNode(QueryNode node)
(node.getParent() instanceof AqpAdsabsSynonymQueryNode && ((AqpAdsabsSynonymQueryNode) node.getParent()).isActivated() == false)) {
subQuery = "{!adismax aqp.exact.search=true}" + subQuery;
}
else if (getConfigVal("aqp.maxPhraseLength", null) != null) {
subQuery = "{!adismax aqp.maxPhraseLength=" + getConfigVal("aqp.maxPhraseLength") + "}" + subQuery;
}

List<OriginalInput> fValues = new ArrayList<OriginalInput>();
fValues.add(new OriginalInput(subQuery, -1, -1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1324,9 +1324,12 @@ private Query getQuery() {
nl.add("aqp.constant_scoring", req.getParams().get("aqp.constant_scoring", ""));

String qs = getQueryStr();
if (localParams != null && localParams.getBool("aqp.exact.search")) {
if (localParams != null && localParams.getBool("aqp.exact.search", false)) {
qs = "=" + qs;
}
if (localParams != null && localParams.get("aqp.maxPhraseLength", null) != null) {
nl.add("aqp.maxPhraseLength", localParams.get("aqp.maxPhraseLength"));
}
// nl.add(CommonParams.DF, field);
nl.add(CommonParams.Q, qs);
localReq = new LocalSolrQueryRequest(req.getCore(), nl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ else if (req != null && req.getSchema().getField(input) != null) {

public void setQueryNode(AqpFunctionQueryNode node) {
this.qNode = node;
this.currChild = -1;
if (node.getOriginalInput() != null) {
sp = new StrParser(node.getOriginalInput().value);
}
Expand Down
11 changes: 11 additions & 0 deletions contrib/adsabs/src/test/org/adsabs/TestAdsAllFields.java
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,17 @@ public void test() throws Exception {
assertQueryEquals(req("q", "abs:\"We use the Hubble Space Telescope (HST) archive of ultraviolet (UV)quasar spectroscopy toconduct the first blind survey for damped Ly-αabsorbers (DLAs) at low redshift (z <1.6). Ourstatistical sample includes 463 quasars with spectral coverage spanning a total redshift path ∆z=123.3 or an absorption path ∆X= 229.7\""),
"like:We use the Hubble Space Telescope (HST) archive of ultraviolet (UV)quasar spectroscopy toconduct the first blind survey for damped Ly-αabsorbers (DLAs) at low redshift (z <1.6). Ourstatistical sample includes 463 quasars with spectral coverage spanning a total redshift path ∆z=123.3 or an absorption path ∆X= 229.7 like:We use the Hubble Space Telescope (HST) archive of ultraviolet (UV)quasar spectroscopy toconduct the first blind survey for damped Ly-αabsorbers (DLAs) at low redshift (z <1.6). Ourstatistical sample includes 463 quasars with spectral coverage spanning a total redshift path ∆z=123.3 or an absorption path ∆X= 229.7 like:We use the Hubble Space Telescope (HST) archive of ultraviolet (UV)quasar spectroscopy toconduct the first blind survey for damped Ly-αabsorbers (DLAs) at low redshift (z <1.6). Ourstatistical sample includes 463 quasars with spectral coverage spanning a total redshift path ∆z=123.3 or an absorption path ∆X= 229.7",
BooleanQuery.class);
// unfielded also must become like query
assertQueryEquals(req("q", "\"Evaluated bimolecular ion molecule gas phase kinetics\"",
"qf", "title abstract",
"aqp.maxPhraseLength", "10"),
"(like:Evaluated bimolecular ion molecule gas phase kinetics | like:Evaluated bimolecular ion molecule gas phase kinetics)",
DisjunctionMaxQuery.class);

// check it can deal with unfielded search
assertQ(req("q", "\"We use the Hubble Space Telescope (HST) archive of ultraviolet (UV)quasar spectroscopy toconduct the first blind survey for damped Ly-αabsorbers (DLAs) at low redshift (z <1.6). Ourstatistical sample includes 463 quasars with spectral coverage spanning a total redshift path ∆z=123.3 or an absorption path ∆X= 229.7. Within this survey path, we identify 4 DLAs definedas absorbers with Hicolumn densityNHi≥1020.3cm−2, which implies an incidence per absorptionlengthℓDLA(X) = 0.017+0.014−0.008at a median survey path redshift ofz= 0.623. While our estimateofℓDLA(X) is lower than earlier estimates atz≈0 from Hi21 cm emission studies, the results areconsistent within the measurement uncertainties. Our dataset is too small to properly sample theNHifrequency distribution functionf(NHi, X), but the observed distribution agrees with previousestimates atz >2. Adopting thez >2 shape off(NHi, X), we infer an Himass density atz∼0.6 ofρDLAHi= 0.25+0.20−0.12×108M⊙Mpc−3. This is significantly lower than previous estimates from targetedDLA surveys with the HST, but consistent with results from low-zHi21 cm observations, and suggeststhat the neutral gas density of the universe has been decreasingover the past 10 Gyrs.\""),
"//*[@numFound='6']"
);



Expand Down

0 comments on commit 3b23d3c

Please sign in to comment.