use of de.ids_mannheim.korap.query.wrap.SpanAlterQueryWrapper in project Krill by KorAP.
the class TestSpanAlterQuery method spanAlterQuery5.
@Test
public void spanAlterQuery5() throws QueryException {
SpanRegexQueryWrapper srequery = new SpanRegexQueryWrapper("field", "a[bc]d.?e");
SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
ssaquery.or("f").or(srequery).or("g");
assertEquals("spanOr([field:f, SpanMultiTermQueryWrapper(field:/a[bc]d.?e/), field:g])", ssaquery.toQuery().toString());
}
use of de.ids_mannheim.korap.query.wrap.SpanAlterQueryWrapper in project Krill by KorAP.
the class TestSpanAlterQuery method spanAlterQuery3.
@Test
public void spanAlterQuery3() throws QueryException {
SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
ssaquery.or("b").or("c").or("d");
assertEquals("spanOr([field:b, field:c, field:d])", ssaquery.toQuery().toString());
}
use of de.ids_mannheim.korap.query.wrap.SpanAlterQueryWrapper in project Krill by KorAP.
the class TestSpanSegmentQuery method spanSegmentAlterQuery.
@Test
public void spanSegmentAlterQuery() throws QueryException {
SpanSegmentQueryWrapper ssquery = new SpanSegmentQueryWrapper("field");
assertNull(ssquery.toQuery());
ssquery.with("a");
assertEquals("field:a", ssquery.toQuery().toString());
ssquery.with(new SpanAlterQueryWrapper("field", "c", "d"));
ssquery.with(new SpanRegexQueryWrapper("field", "a.*b"));
assertEquals("spanSegment(spanSegment(field:a, spanOr([field:c, field:d])), SpanMultiTermQueryWrapper(field:/a.*b/))", ssquery.toQuery().toString());
}
use of de.ids_mannheim.korap.query.wrap.SpanAlterQueryWrapper in project Krill by KorAP.
the class TestSpanSegmentAlterQuery method spanAlterQuery4.
@Test
public void spanAlterQuery4() throws QueryException {
SpanSegmentQueryWrapper segquery = new SpanSegmentQueryWrapper("field", "a", "b", "c");
SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
ssaquery.or("d").or(segquery).or("e");
assertEquals("spanOr([field:d, spanSegment(spanSegment(field:a, field:b), field:c), field:e])", ssaquery.toQuery().toString());
}
use of de.ids_mannheim.korap.query.wrap.SpanAlterQueryWrapper in project Krill by KorAP.
the class KrillQuery method _handleAttrGroup.
// Deserialize attribute groups
private SpanQueryWrapper _handleAttrGroup(SpanQueryWrapper elementWithIdWrapper, JsonNode attrNode) throws QueryException {
if (!attrNode.has("relation")) {
throw new QueryException(743, "Term group expects a relation");
}
if (!attrNode.has("operands")) {
throw new QueryException(742, "Term group needs operand list");
}
String relation = attrNode.get("relation").asText();
JsonNode operands = attrNode.get("operands");
SpanQueryWrapper attrWrapper;
if ("relation:and".equals(relation)) {
List<SpanQueryWrapper> wrapperList = new ArrayList<SpanQueryWrapper>();
for (JsonNode operand : operands) {
attrWrapper = _termFromJson(operand);
if (attrWrapper == null) {
throw new QueryException(747, "Attribute is null");
}
wrapperList.add(attrWrapper);
}
if (elementWithIdWrapper != null) {
return new SpanWithAttributeQueryWrapper(elementWithIdWrapper, wrapperList);
} else {
return new SpanWithAttributeQueryWrapper(wrapperList);
}
} else if ("relation:or".equals(relation)) {
SpanAlterQueryWrapper saq = new SpanAlterQueryWrapper(field);
SpanWithAttributeQueryWrapper saqw;
for (JsonNode operand : operands) {
attrWrapper = _termFromJson(operand);
if (attrWrapper == null) {
throw new QueryException(747, "Attribute is null");
}
if (elementWithIdWrapper != null) {
saqw = new SpanWithAttributeQueryWrapper(elementWithIdWrapper, attrWrapper);
} else {
saqw = new SpanWithAttributeQueryWrapper(attrWrapper);
}
saq.or(saqw);
}
return saq;
} else {
throw new QueryException(716, "Unknown relation");
}
}
Aggregations