Query generator should not treat quoted phrases specially.

Quoted strings in CQL only have syntactic meaning for the parser, they don't carry semantic meaning for the resulting query.

As a consequence of this change, they have to be used in their unquoted form (`tok2.getString()` instead of `arg2.toString()`).

NOTE: The `cql.unmasked` relation modifier may be implemented in order to support the previous behaviour of "protected" phrases.
This commit is contained in:
Jens Wille 2017-01-26 15:36:07 +01:00
parent 1331ad631e
commit 57d757352a
3 changed files with 11 additions and 10 deletions

View file

@ -194,17 +194,10 @@ public class QueryGenerator implements Visitor {
break;
}
case PHRASE: {
String field = arg1.toString();
String value = arg2 != null ? arg2.toString() : "";
if (tok2 != null) {
if (tok2.isQuoted()) {
builder.startObject("match_phrase")
.startObject(field)
.field("query", tok2.getString())
.field("slop", 0)
.endObject()
.endObject();
} else if (tok2.isAll()) {
String field = arg1.toString();
String value = tok2.isQuoted() ? tok2.getString() : arg2.toString();
if (tok2.isAll()) {
builder.startObject("match_all").endObject();
} else if (tok2.isWildcard()) {
builder.startObject("wildcard").field(field, value).endObject();

View file

@ -121,3 +121,7 @@ unix and facet.creator = "on" and facet.subject = "on" and facet.date = "off"|{"
unix and facet.date = on|{"from":0,"size":10,"query":{"bool":{"must":{"simple_query_string":{"query":"unix","fields":["cql.allIndexes"],"analyze_wildcard":true,"default_operator":"and"}}}},"aggregations":{"myfacet":"myvalue"}}
(cql.allIndexes = "")|{"from":0,"size":10,"query":{"simple_query_string":{"query":"\"\"","fields":["cql.allIndexes"],"analyze_wildcard":true,"default_operator":"and"}}}
cql.allIndexes all 3125294126|{"from":0,"size":10,"query":{"simple_query_string":{"query":"3125294126","fields":["cql.allIndexes"],"analyze_wildcard":true,"default_operator":"and"}}}
Item.callnumber adj QAP2230|{"from":0,"size":10,"query":{"match_phrase":{"Item.callnumber":{"query":"QAP2230","slop":0}}}}
Item.callnumber adj QAP22*|{"from":0,"size":10,"query":{"wildcard":{"Item.callnumber":"QAP22*"}}}
Item.callnumber adj "K 32/70 A 10"|{"from":0,"size":10,"query":{"match_phrase":{"Item.callnumber":{"query":"K 32/70 A 10","slop":0}}}}
Item.callnumber adj "K 32/70 A*"|{"from":0,"size":10,"query":{"wildcard":{"Item.callnumber":"K 32/70 A*"}}}

View file

@ -139,3 +139,7 @@ unix and facet.dc.creator = "on" and facet.dc.subject = "on" and facet.dc.subjec
unix and facet.dc.date = "on" and facet.dc.subject = "on" and facet.dc.subject = "buckets=20"|unix
unix and facet.dc.creator = "on" and facet.dc.subject = "on" and facet.dc.subject = "buckets=20"|unix
cql.allIndexes all "linux;"
Item.callnumber adj QAP2230
Item.callnumber adj QAP22*
Item.callnumber adj "K 32/70 A 10"
Item.callnumber adj "K 32/70 A*"