Skip to content

Commit

Permalink
Ignore case when we are expanding search into a phrase search
Browse files Browse the repository at this point in the history
  • Loading branch information
romanchyla committed Apr 16, 2021
1 parent 1bf928f commit 6a7e385
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,14 @@ private void removeField(QueryNode n) {

}


private QueryNode createReplacementNode(List<NodeInfo> newGroup, String tt) throws CloneNotSupportedException, QueryNodeException {
String newValue = getConcatenatedValue(newGroup);

if (newValue != newValue.toLowerCase() && newValue == newValue.toUpperCase() && newGroup.size() > getMaxAllowedAcronym()) {
newValue = newValue.toLowerCase();
}

String field = "";
if (newGroup.get(0).getField() != null && newGroup.get(0).getField().length() > 0)
field = newGroup.get(0).getField() + ":";
Expand Down Expand Up @@ -411,7 +417,14 @@ private QueryNode createReplacementNode(List<NodeInfo> newGroup, String tt) thro



/*
private int getMaxAllowedAcronym() {
Object obj = _getConfigVal("aqp.unfielded.max.uppercase.tokens");
if (obj == null)
return 1024; //effectively unlimited
return Integer.parseInt((String)obj);
}

/*
* Ufff....this is necessary, because the QueryNodeImpl is NOT
* resetting the parent. sooooo stupid....
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ public Query parse() throws SyntaxError {
// QueryConfigHandler config = qParser.getQueryConfigHandler();
// return qParser.parse(getString() + config.get(AqpAdsabsQueryConfigHandler.ConfigurationKeys.DUMMY_VALUE), null);
//}

return qParser.parse(getString(), null);
} catch (QueryNodeException e) {
throw new SyntaxError(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,16 @@ public void tearDown() throws Exception {


public void testUnfieldedSearch() throws Exception {


// when we generate the phrase search, ignore acronyms
assertQueryEquals(req("defType", "aqp",
"q", "FOO BAR BAZ",
"aqp.unfielded.tokens.strategy", "disjuncts",
"aqp.unfielded.tokens.new.type", "simple",
"aqp.unfielded.max.uppercase.tokens", "2",
"qf", "title"),
"(((title:foo) (title:bar) (title:baz)) | title:\"foo bar baz\")",
DisjunctionMaxQuery.class);

// have constant scoring work even for unfielded searches
assertQueryEquals(req("defType", "aqp", "q", "foo bar",
Expand Down
2 changes: 1 addition & 1 deletion contrib/examples/adsabs/bin/solr.in.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ SOLR_OPTS="${SOLR_OPTS} -Xss256k \
-Dmontysolr.load.citation_cache=${MONTYSOLR_LOAD_CITATION_CACHE:-true} \
-Dmontysolr.autoCommit.maxDocs=${MONTYSOLR_MAX_DOCS:-40000} \
-Dmontysolr.autoCommit.maxTime=${MONTYSOLR_MAX_TIME:-1800000} \
-Dmontysolr.autoSoftCommit.maxTime=${MONTYSOLR_SOFT_MAX_TIME:-900000} \
-Dmontysolr.autoSoftCommit.maxTime=${MONTYSOLR_SOFT_MAX_TIME:-1} \
-Dmontysolr.coordinate=${MONTYSOLR_COORDINATE:-true} \
-Dmontysolr.stagger.maxDelay=${MONTYSOLR_STAGGER_MAX_DELAY:-2700} \
-Dmontysolr.stagger.numInstances=${MONTYSOLR_STAGGER_NUM_INSTANCES:-3} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
<str name="aqp.constant_scoring">first_author^14 author^13 year^10 bibstem^10</str>
<str name="aqp.multiphrase.keep_one">SYNONYM</str>
<str name="aqp.multiphrase.keep_one.ignore.fields">aff_raw,aff_id,institution</str>

<str name="aqp.unfielded.max.uppercase.tokens">2</str>
<str name="q.op">AND</str>

</lst>
Expand Down Expand Up @@ -372,7 +372,7 @@
<str name="aqp.constant_scoring">first_author^14 author^13 year^10 bibstem^10</str>
<str name="aqp.multiphrase.keep_one">SYNONYM</str>
<str name="aqp.multiphrase.keep_one.ignore.fields">aff_raw,aff_id,institution</str>

<str name="aqp.unfielded.max.uppercase.tokens">2</str>
<str name="q.op">AND</str>
<str name="df">unfielded_search</str>
</lst>
Expand Down Expand Up @@ -426,7 +426,7 @@
<str name="aqp.unfielded.tokens.function.name">edismax_combined_aqp</str>
<str name="useFastVectorHighlighter">true</str>
<str name="aqp.allow.leading_wildcard">true</str>

<str name="aqp.unfielded.max.uppercase.tokens">2</str>
<str name="q.op">AND</str>
<str name="df">unfielded_search</str>
</lst>
Expand Down

0 comments on commit 6a7e385

Please sign in to comment.