From b42a79c26a1a37f703653dc7fd217a2c8377c641 Mon Sep 17 00:00:00 2001 From: Matthew Davis Date: Mon, 10 Jul 2023 13:58:03 -0400 Subject: [PATCH] Zulia Set Syntax (#114) * grammar changes for adding field:zl:ns and field:zl:tq syntax * generated code changes for adding field:zl:ns and field:zl:tq syntax * refactor out term query and numeric set query code into SetQuery Helper * implement new query syntax for field:zl:ns and field:zl:tq syntax in actual parser * upgrade flapdoodle to 4.7.0 from 3.5.2 * fix spacing in exception * fix exception when field is not set in the directly query (set via default fields) * numeric set syntax tests * add tests for querying fields with names zl and fl * add term query syntax test * add quoted example --- .../java/io/zulia/client/pool/ZuliaPool.java | 2 +- .../search/queryparser/SetQueryHelper.java | 110 +++ .../ZuliaFieldableQueryNodeBuilder.java | 23 + .../builder/ZuliaQueryTreeBuilder.java | 2 + .../node/ZuliaFieldableQueryNode.java | 31 + .../node/ZuliaNumericSetQueryNode.java | 75 ++ .../node/ZuliaTermsInSetQueryNode.java | 57 ++ .../queryparser/parser/ZuliaSyntaxParser.java | 770 +++++++++++------- .../queryparser/parser/ZuliaSyntaxParser.jj | 56 +- .../parser/ZuliaSyntaxParserConstants.java | 120 +-- .../parser/ZuliaSyntaxParserTokenManager.java | 757 ++++++++++------- .../ZuliaFieldableQueryNodeProcessor.java | 43 + .../ZuliaQueryNodeProcessorPipeline.java | 2 + .../io/zulia/server/index/ZuliaIndex.java | 109 +-- .../server/test/node/NumericSetTest.java | 99 +++ .../zulia/server/test/node/StartStopTest.java | 35 + 16 files changed, 1570 insertions(+), 721 deletions(-) create mode 100644 zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/SetQueryHelper.java create mode 100644 zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/builder/ZuliaFieldableQueryNodeBuilder.java create mode 100644 zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/node/ZuliaFieldableQueryNode.java create mode 100644 zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/node/ZuliaNumericSetQueryNode.java create mode 100644 zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/node/ZuliaTermsInSetQueryNode.java create mode 100644 zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/processors/ZuliaFieldableQueryNodeProcessor.java diff --git a/zulia-client/src/main/java/io/zulia/client/pool/ZuliaPool.java b/zulia-client/src/main/java/io/zulia/client/pool/ZuliaPool.java index c7d10492..8be2dae9 100644 --- a/zulia-client/src/main/java/io/zulia/client/pool/ZuliaPool.java +++ b/zulia-client/src/main/java/io/zulia/client/pool/ZuliaPool.java @@ -229,7 +229,7 @@ else if (command instanceof MultiIndexRoutableCommand) { throw new Exception(grpcCommand.getClass().getSimpleName() + ": " + errorMessage); } else { - throw new IllegalArgumentException(grpcCommand.getClass().getSimpleName() + ":" + errorMessage); + throw new IllegalArgumentException(grpcCommand.getClass().getSimpleName() + ": " + errorMessage); } } else { diff --git a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/SetQueryHelper.java b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/SetQueryHelper.java new file mode 100644 index 00000000..383c6eff --- /dev/null +++ b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/SetQueryHelper.java @@ -0,0 +1,110 @@ +package io.zulia.server.search.queryparser; + +import io.zulia.message.ZuliaIndex; +import io.zulia.server.config.IndexFieldInfo; +import io.zulia.server.field.FieldTypeUtil; +import org.apache.lucene.document.DoublePoint; +import org.apache.lucene.document.FloatPoint; +import org.apache.lucene.document.IntPoint; +import org.apache.lucene.document.LongPoint; +import org.apache.lucene.document.SortedNumericDocValuesField; +import org.apache.lucene.search.IndexOrDocValuesQuery; +import org.apache.lucene.search.MultiTermQuery; +import org.apache.lucene.search.Query; +import org.apache.lucene.search.TermInSetQuery; +import org.apache.lucene.util.BytesRef; +import org.apache.lucene.util.NumericUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Supplier; + +public class SetQueryHelper { + + public static Query getNumericSetQuery(String field, IndexFieldInfo indexFieldInfo, Supplier> intSupplier, Supplier> longSupplier, + Supplier> floatSupplier, Supplier> doubleSupplier) { + ZuliaIndex.FieldConfig.FieldType fieldType = indexFieldInfo.getFieldType(); + String searchField = indexFieldInfo.getInternalFieldName(); + String sortField = indexFieldInfo.getInternalSortFieldName(); + + if (fieldType == null) { + throw new IllegalArgumentException("Field <" + field + "> is not indexed"); + } + else { + if (FieldTypeUtil.isNumericIntFieldType(fieldType)) { + List integerValueList = intSupplier.get(); + if (integerValueList.isEmpty()) { + throw new IllegalArgumentException("No integer values for integer field <" + field + "> for numeric set query"); + } + + Query pointQuery = IntPoint.newSetQuery(searchField, integerValueList); + if (sortField == null) { + return pointQuery; + } + long[] pointsArray = integerValueList.stream().mapToLong(Integer::intValue).toArray(); + return new IndexOrDocValuesQuery(pointQuery, SortedNumericDocValuesField.newSlowSetQuery(sortField, pointsArray)); + } + else if (FieldTypeUtil.isNumericLongFieldType(fieldType)) { + List longValueList = longSupplier.get(); + if (longValueList.isEmpty()) { + throw new IllegalArgumentException("No long values for long field <" + field + "> for numeric set query"); + } + + Query pointQuery = LongPoint.newSetQuery(searchField, longValueList); + if (sortField == null) { + return pointQuery; + } + long[] pointsArray = longValueList.stream().mapToLong(Long::longValue).toArray(); + return new IndexOrDocValuesQuery(pointQuery, SortedNumericDocValuesField.newSlowSetQuery(sortField, pointsArray)); + } + else if (FieldTypeUtil.isNumericFloatFieldType(fieldType)) { + List floatValueList = floatSupplier.get(); + if (floatValueList.isEmpty()) { + throw new IllegalArgumentException("No float values for float field <" + field + "> for numeric set query"); + } + + Query pointQuery = FloatPoint.newSetQuery(searchField, floatValueList); + if (sortField == null) { + return pointQuery; + } + long[] pointsArray = floatValueList.stream().mapToLong(NumericUtils::floatToSortableInt).toArray(); + return new IndexOrDocValuesQuery(pointQuery, SortedNumericDocValuesField.newSlowSetQuery(sortField, pointsArray)); + } + else if (FieldTypeUtil.isNumericDoubleFieldType(fieldType)) { + List doubleValueList = doubleSupplier.get(); + if (doubleValueList.isEmpty()) { + throw new IllegalArgumentException("No double values for double field <" + field + "> for numeric set query"); + } + + Query pointQuery = DoublePoint.newSetQuery(searchField, doubleValueList); + if (sortField == null) { + return pointQuery; + } + long[] pointsArray = doubleValueList.stream().mapToLong(NumericUtils::doubleToSortableLong).toArray(); + return new IndexOrDocValuesQuery(pointQuery, SortedNumericDocValuesField.newSlowSetQuery(sortField, pointsArray)); + } + } + throw new IllegalArgumentException("No field type of <" + fieldType + "> is not supported for numeric set queries"); + } + + public static Query getTermInSetQuery(List terms, String field, IndexFieldInfo indexFieldInfo) { + List termBytesRef = new ArrayList<>(); + for (String term : terms) { + termBytesRef.add(new BytesRef(term)); + } + + if (FieldTypeUtil.isStringFieldType(indexFieldInfo.getFieldType())) { + String sortField = indexFieldInfo.getInternalSortFieldName(); + + if (sortField != null) { + Query indexQuery = new TermInSetQuery(field, termBytesRef); + Query dvQuery = new TermInSetQuery(MultiTermQuery.DOC_VALUES_REWRITE, sortField, termBytesRef); + return new IndexOrDocValuesQuery(indexQuery, dvQuery); + } + + return new TermInSetQuery(field, termBytesRef); + } + throw new IllegalArgumentException( + "Field type of <" + indexFieldInfo.getFieldType() + "> is not supported for term queries. Only STRING is supported."); + } +} diff --git a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/builder/ZuliaFieldableQueryNodeBuilder.java b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/builder/ZuliaFieldableQueryNodeBuilder.java new file mode 100644 index 00000000..5e77694e --- /dev/null +++ b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/builder/ZuliaFieldableQueryNodeBuilder.java @@ -0,0 +1,23 @@ +package io.zulia.server.search.queryparser.builder; + +import io.zulia.server.search.queryparser.node.ZuliaFieldableQueryNode; +import org.apache.lucene.queryparser.flexible.core.QueryNodeException; +import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; +import org.apache.lucene.queryparser.flexible.standard.builders.StandardQueryBuilder; +import org.apache.lucene.search.Query; + +public class ZuliaFieldableQueryNodeBuilder implements StandardQueryBuilder { + + /** + * Constructs a {@link ZuliaFieldableQueryNodeBuilder} object. + */ + public ZuliaFieldableQueryNodeBuilder() { + // empty constructor + } + + @Override + public Query build(QueryNode queryNode) throws QueryNodeException { + ZuliaFieldableQueryNode fieldableQueryNode = (ZuliaFieldableQueryNode) queryNode; + return fieldableQueryNode.getQuery(); + } +} diff --git a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/builder/ZuliaQueryTreeBuilder.java b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/builder/ZuliaQueryTreeBuilder.java index 18e02b2f..c270a67e 100644 --- a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/builder/ZuliaQueryTreeBuilder.java +++ b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/builder/ZuliaQueryTreeBuilder.java @@ -1,5 +1,6 @@ package io.zulia.server.search.queryparser.builder; +import io.zulia.server.search.queryparser.node.ZuliaFieldableQueryNode; import io.zulia.server.search.queryparser.node.ZuliaPointRangeQueryNode; import org.apache.lucene.queryparser.flexible.standard.builders.StandardQueryTreeBuilder; @@ -7,6 +8,7 @@ public class ZuliaQueryTreeBuilder extends StandardQueryTreeBuilder { public ZuliaQueryTreeBuilder() { setBuilder(ZuliaPointRangeQueryNode.class, new ZuliaPointRangeQueryNodeBuilder()); + setBuilder(ZuliaFieldableQueryNode.class, new ZuliaFieldableQueryNodeBuilder()); } } diff --git a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/node/ZuliaFieldableQueryNode.java b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/node/ZuliaFieldableQueryNode.java new file mode 100644 index 00000000..fb1988cb --- /dev/null +++ b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/node/ZuliaFieldableQueryNode.java @@ -0,0 +1,31 @@ +package io.zulia.server.search.queryparser.node; + +import io.zulia.server.config.IndexFieldInfo; +import org.apache.lucene.queryparser.flexible.core.nodes.FieldableNode; +import org.apache.lucene.queryparser.flexible.core.nodes.QueryNodeImpl; +import org.apache.lucene.search.Query; + +public abstract class ZuliaFieldableQueryNode extends QueryNodeImpl implements FieldableNode { + private CharSequence field; + private IndexFieldInfo indexFieldInfo; + + @Override + public CharSequence getField() { + return field; + } + + @Override + public void setField(CharSequence fieldName) { + this.field = fieldName != null ? fieldName.toString() : null; + } + + public abstract Query getQuery(); + + public void setIndexFieldInfo(IndexFieldInfo indexFieldInfo) { + this.indexFieldInfo = indexFieldInfo; + } + + public IndexFieldInfo getIndexFieldInfo() { + return indexFieldInfo; + } +} diff --git a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/node/ZuliaNumericSetQueryNode.java b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/node/ZuliaNumericSetQueryNode.java new file mode 100644 index 00000000..fb3c2cdd --- /dev/null +++ b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/node/ZuliaNumericSetQueryNode.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.zulia.server.search.queryparser.node; + +import io.zulia.server.search.queryparser.SetQueryHelper; +import org.apache.lucene.queryparser.flexible.core.parser.EscapeQuerySyntax; +import org.apache.lucene.queryparser.flexible.standard.parser.EscapeQuerySyntaxImpl; +import org.apache.lucene.search.Query; + +import java.util.List; +import java.util.Locale; +import java.util.Objects; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +public class ZuliaNumericSetQueryNode extends ZuliaFieldableQueryNode { + private final List terms; + + public ZuliaNumericSetQueryNode(CharSequence field, List terms) { + setField(field); + this.terms = Objects.requireNonNull(terms); + } + + public Query getQuery() { + Objects.requireNonNull(getField(), "Field must not be null for numeric set queries"); + Objects.requireNonNull(getIndexFieldInfo(), "Field <" + getField() + "> must be indexed for numeric set queries"); + return SetQueryHelper.getNumericSetQuery(getField().toString(), getIndexFieldInfo(), intTerms(), longTerms(), floatTerms(), doubleTerms()); + } + + public Supplier> intTerms() { + return () -> terms.stream().map(Object::toString).map(Integer::parseInt).collect(Collectors.toList()); + } + + public Supplier> longTerms() { + return () -> terms.stream().map(Object::toString).map(Long::parseLong).collect(Collectors.toList()); + } + + public Supplier> floatTerms() { + return () -> terms.stream().map(Object::toString).map(Float::parseFloat).collect(Collectors.toList()); + } + + public Supplier> doubleTerms() { + return () -> terms.stream().map(Object::toString).map(Double::parseDouble).collect(Collectors.toList()); + } + + @Override + public String toQueryString(EscapeQuerySyntax escapeSyntaxParser) { + return String.format(Locale.ROOT, "%s:numericSet(%s)", getField(), terms); + } + + @Override + public String toString() { + return toQueryString(new EscapeQuerySyntaxImpl()); + } + + @Override + public ZuliaNumericSetQueryNode cloneTree() { + return new ZuliaNumericSetQueryNode(getField(), terms); + } + +} diff --git a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/node/ZuliaTermsInSetQueryNode.java b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/node/ZuliaTermsInSetQueryNode.java new file mode 100644 index 00000000..5204b67e --- /dev/null +++ b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/node/ZuliaTermsInSetQueryNode.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.zulia.server.search.queryparser.node; + +import io.zulia.server.search.queryparser.SetQueryHelper; +import org.apache.lucene.queryparser.flexible.core.parser.EscapeQuerySyntax; +import org.apache.lucene.queryparser.flexible.standard.parser.EscapeQuerySyntaxImpl; +import org.apache.lucene.search.Query; + +import java.util.List; +import java.util.Locale; +import java.util.Objects; + +public class ZuliaTermsInSetQueryNode extends ZuliaFieldableQueryNode { + private final List terms; + + public ZuliaTermsInSetQueryNode(CharSequence field, List terms) { + setField(field); + this.terms = Objects.requireNonNull(terms); + } + + public Query getQuery() { + Objects.requireNonNull(getField(), "Field must not be null for term set queries."); + Objects.requireNonNull(getIndexFieldInfo(), "Field <" + getField() + "> must be indexed for term set queries"); + return SetQueryHelper.getTermInSetQuery(terms.stream().map(Object::toString).toList(), getField().toString(), getIndexFieldInfo()); + } + + @Override + public String toQueryString(EscapeQuerySyntax escapeSyntaxParser) { + return String.format(Locale.ROOT, "%s:termQuery(%s)", getField(), terms); + } + + @Override + public String toString() { + return toQueryString(new EscapeQuerySyntaxImpl()); + } + + @Override + public ZuliaTermsInSetQueryNode cloneTree() { + return new ZuliaTermsInSetQueryNode(getField(), terms); + } + +} diff --git a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/parser/ZuliaSyntaxParser.java b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/parser/ZuliaSyntaxParser.java index cea7cd1f..94f69e4c 100644 --- a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/parser/ZuliaSyntaxParser.java +++ b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/parser/ZuliaSyntaxParser.java @@ -19,6 +19,9 @@ * limitations under the License. */ +import io.zulia.server.search.queryparser.node.ZuliaFieldableQueryNode; +import io.zulia.server.search.queryparser.node.ZuliaNumericSetQueryNode; +import io.zulia.server.search.queryparser.node.ZuliaTermsInSetQueryNode; import org.apache.lucene.queryparser.charstream.CharStream; import org.apache.lucene.queryparser.charstream.FastCharStream; import org.apache.lucene.queryparser.flexible.core.QueryNodeParseException; @@ -112,6 +115,7 @@ final private QueryNode Query(CharSequence field) throws ParseException { switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { case NOT: case FN_PREFIX: + case ZL_PREFIX: case PLUS: case MINUS: case QUOTED: @@ -262,6 +266,7 @@ final private QueryNode Clause(CharSequence field) throws ParseException { else { switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { case FN_PREFIX: + case ZL_PREFIX: case QUOTED: case NUMBER: case TERM: @@ -305,6 +310,10 @@ final private QueryNode Clause(CharSequence field) throws ParseException { q = IntervalExpr(field); break; } + case ZL_PREFIX: { + q = ZuliaExpr(field); + break; + } default: jj_la1[7] = jj_gen; jj_consume_token(-1); @@ -353,14 +362,14 @@ final private QueryNode GroupingExpr(CharSequence field) throws ParseException { } switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { case TILDE: - case 56: { + case 59: { switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { case TILDE: { jj_consume_token(TILDE); break; } - case 56: { - jj_consume_token(56); + case 59: { + jj_consume_token(59); break; } default: @@ -388,6 +397,129 @@ final private QueryNode GroupingExpr(CharSequence field) throws ParseException { throw new Error("Missing return statement in function"); } + final private ZuliaFieldableQueryNode ZuliaExpr(CharSequence field) throws ParseException { + ZuliaFieldableQueryNode source; + if (jj_2_4(2)) { + source = NumericsSetQuery(field); + { + if ("" != null) + return source; + } + } + else if (jj_2_5(2)) { + source = TermsInSetQuery(field); + { + if ("" != null) + return source; + } + } + else { + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } + + final private ZuliaNumericSetQueryNode NumericsSetQuery(CharSequence field) throws ParseException { + CharSequence value; + ArrayList values = new ArrayList(); + jj_consume_token(ZL_PREFIX); + jj_consume_token(NUMERIC_SET); + jj_consume_token(LPAREN); + label_4: + while (true) { + value = TermText(); + values.add(value); + switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { + case QUOTED: + case NUMBER: + case TERM: { + ; + break; + } + default: + jj_la1[12] = jj_gen; + break label_4; + } + } + jj_consume_token(RPAREN); + { + if ("" != null) + return new ZuliaNumericSetQueryNode(field, values); + } + throw new Error("Missing return statement in function"); + } + + final private ZuliaTermsInSetQueryNode TermsInSetQuery(CharSequence field) throws ParseException { + CharSequence value; + ArrayList values = new ArrayList(); + jj_consume_token(ZL_PREFIX); + jj_consume_token(TERM_SET); + jj_consume_token(LPAREN); + label_5: + while (true) { + value = TermText(); + values.add(value); + switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { + case QUOTED: + case NUMBER: + case TERM: { + ; + break; + } + default: + jj_la1[13] = jj_gen; + break label_5; + } + } + jj_consume_token(RPAREN); + { + if ("" != null) + return new ZuliaTermsInSetQueryNode(field, values); + } + throw new Error("Missing return statement in function"); + } + + final private CharSequence TermText() throws ParseException { + switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { + case QUOTED: { + jj_consume_token(QUOTED); + { + if ("" != null) + return token.image.substring(1, token.image.length() - 1); + } + break; + } + case NUMBER: + case TERM: { + switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) { + case TERM: { + jj_consume_token(TERM); + break; + } + case NUMBER: { + jj_consume_token(NUMBER); + break; + } + default: + jj_la1[14] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + { + if ("" != null) + return token.image; + } + break; + } + default: + jj_la1[15] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } + final private IntervalQueryNode IntervalExpr(CharSequence field) throws ParseException { IntervalFunction source; source = IntervalFun(); @@ -400,154 +532,154 @@ final private IntervalQueryNode IntervalExpr(CharSequence field) throws ParseExc final private IntervalFunction IntervalFun() throws ParseException { IntervalFunction source; - if (jj_2_4(2)) { + if (jj_2_6(2)) { source = IntervalAtLeast(); { if ("" != null) return source; } } - else if (jj_2_5(2)) { + else if (jj_2_7(2)) { source = IntervalMaxWidth(); { if ("" != null) return source; } } - else if (jj_2_6(2)) { + else if (jj_2_8(2)) { source = IntervalMaxGaps(); { if ("" != null) return source; } } - else if (jj_2_7(2)) { + else if (jj_2_9(2)) { source = IntervalOrdered(); { if ("" != null) return source; } } - else if (jj_2_8(2)) { + else if (jj_2_10(2)) { source = IntervalUnordered(); { if ("" != null) return source; } } - else if (jj_2_9(2)) { + else if (jj_2_11(2)) { source = IntervalUnorderedNoOverlaps(); { if ("" != null) return source; } } - else if (jj_2_10(2)) { + else if (jj_2_12(2)) { source = IntervalOr(); { if ("" != null) return source; } } - else if (jj_2_11(2)) { + else if (jj_2_13(2)) { source = IntervalWildcard(); { if ("" != null) return source; } } - else if (jj_2_12(2)) { + else if (jj_2_14(2)) { source = IntervalAfter(); { if ("" != null) return source; } } - else if (jj_2_13(2)) { + else if (jj_2_15(2)) { source = IntervalBefore(); { if ("" != null) return source; } } - else if (jj_2_14(2)) { + else if (jj_2_16(2)) { source = IntervalPhrase(); { if ("" != null) return source; } } - else if (jj_2_15(2)) { + else if (jj_2_17(2)) { source = IntervalContaining(); { if ("" != null) return source; } } - else if (jj_2_16(2)) { + else if (jj_2_18(2)) { source = IntervalNotContaining(); { if ("" != null) return source; } } - else if (jj_2_17(2)) { + else if (jj_2_19(2)) { source = IntervalContainedBy(); { if ("" != null) return source; } } - else if (jj_2_18(2)) { + else if (jj_2_20(2)) { source = IntervalNotContainedBy(); { if ("" != null) return source; } } - else if (jj_2_19(2)) { + else if (jj_2_21(2)) { source = IntervalWithin(); { if ("" != null) return source; } } - else if (jj_2_20(2)) { + else if (jj_2_22(2)) { source = IntervalNotWithin(); { if ("" != null) return source; } } - else if (jj_2_21(2)) { + else if (jj_2_23(2)) { source = IntervalOverlapping(); { if ("" != null) return source; } } - else if (jj_2_22(2)) { + else if (jj_2_24(2)) { source = IntervalNonOverlapping(); { if ("" != null) return source; } } - else if (jj_2_23(2)) { + else if (jj_2_25(2)) { source = IntervalExtend(); { if ("" != null) return source; } } - else if (jj_2_24(2)) { + else if (jj_2_26(2)) { source = IntervalFuzzyTerm(); { if ("" != null) return source; } } - else if (jj_2_25(2)) { + else if (jj_2_27(2)) { source = IntervalText(); { if ("" != null) @@ -569,7 +701,7 @@ final private IntervalFunction IntervalAtLeast() throws ParseException { jj_consume_token(ATLEAST); jj_consume_token(LPAREN); minShouldMatch = jj_consume_token(NUMBER); - label_4: + label_6: while (true) { source = IntervalFun(); sources.add(source); @@ -582,8 +714,8 @@ final private IntervalFunction IntervalAtLeast() throws ParseException { break; } default: - jj_la1[12] = jj_gen; - break label_4; + jj_la1[16] = jj_gen; + break label_6; } } jj_consume_token(RPAREN); @@ -632,7 +764,7 @@ final private IntervalFunction IntervalUnordered() throws ParseException { jj_consume_token(FN_PREFIX); jj_consume_token(UNORDERED); jj_consume_token(LPAREN); - label_5: + label_7: while (true) { source = IntervalFun(); sources.add(source); @@ -645,8 +777,8 @@ final private IntervalFunction IntervalUnordered() throws ParseException { break; } default: - jj_la1[13] = jj_gen; - break label_5; + jj_la1[17] = jj_gen; + break label_7; } } jj_consume_token(RPAREN); @@ -678,7 +810,7 @@ final private IntervalFunction IntervalOrdered() throws ParseException { jj_consume_token(FN_PREFIX); jj_consume_token(ORDERED); jj_consume_token(LPAREN); - label_6: + label_8: while (true) { source = IntervalFun(); sources.add(source); @@ -691,8 +823,8 @@ final private IntervalFunction IntervalOrdered() throws ParseException { break; } default: - jj_la1[14] = jj_gen; - break label_6; + jj_la1[18] = jj_gen; + break label_8; } } jj_consume_token(RPAREN); @@ -709,7 +841,7 @@ final private IntervalFunction IntervalOr() throws ParseException { jj_consume_token(FN_PREFIX); jj_consume_token(FN_OR); jj_consume_token(LPAREN); - label_7: + label_9: while (true) { source = IntervalFun(); sources.add(source); @@ -722,8 +854,8 @@ final private IntervalFunction IntervalOr() throws ParseException { break; } default: - jj_la1[15] = jj_gen; - break label_7; + jj_la1[19] = jj_gen; + break label_9; } } jj_consume_token(RPAREN); @@ -740,7 +872,7 @@ final private IntervalFunction IntervalPhrase() throws ParseException { jj_consume_token(FN_PREFIX); jj_consume_token(PHRASE); jj_consume_token(LPAREN); - label_8: + label_10: while (true) { source = IntervalFun(); sources.add(source); @@ -753,8 +885,8 @@ final private IntervalFunction IntervalPhrase() throws ParseException { break; } default: - jj_la1[16] = jj_gen; - break label_8; + jj_la1[20] = jj_gen; + break label_10; } } jj_consume_token(RPAREN); @@ -961,7 +1093,7 @@ final private IntervalFunction IntervalWildcard() throws ParseException { break; } default: - jj_la1[17] = jj_gen; + jj_la1[21] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -974,7 +1106,7 @@ final private IntervalFunction IntervalWildcard() throws ParseException { break; } default: - jj_la1[18] = jj_gen; + jj_la1[22] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -984,7 +1116,7 @@ final private IntervalFunction IntervalWildcard() throws ParseException { break; } default: - jj_la1[19] = jj_gen; + jj_la1[23] = jj_gen; ; } jj_consume_token(RPAREN); @@ -1015,7 +1147,7 @@ final private IntervalFunction IntervalFuzzyTerm() throws ParseException { break; } default: - jj_la1[20] = jj_gen; + jj_la1[24] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1028,17 +1160,17 @@ final private IntervalFunction IntervalFuzzyTerm() throws ParseException { break; } default: - jj_la1[21] = jj_gen; + jj_la1[25] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - if (jj_2_26(2)) { + if (jj_2_28(2)) { maxEdits = jj_consume_token(NUMBER); } else { ; } - if (jj_2_27(2)) { + if (jj_2_29(2)) { maxExpansions = jj_consume_token(NUMBER); } else { @@ -1074,7 +1206,7 @@ final private IntervalFunction IntervalText() throws ParseException { break; } default: - jj_la1[22] = jj_gen; + jj_la1[26] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1085,7 +1217,7 @@ final private IntervalFunction IntervalText() throws ParseException { break; } default: - jj_la1[23] = jj_gen; + jj_la1[27] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1106,7 +1238,7 @@ final private QueryNode Boost(QueryNode node) throws ParseException { final private QueryNode FuzzyOp(CharSequence field, Token term, QueryNode node) throws ParseException { Token similarity = null; jj_consume_token(TILDE); - if (jj_2_28(2)) { + if (jj_2_30(2)) { similarity = jj_consume_token(NUMBER); } else { @@ -1158,7 +1290,7 @@ final private TermRangeQueryNode FieldRangeExpr(CharSequence field) throws Parse break; } default: - jj_la1[24] = jj_gen; + jj_la1[28] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1177,7 +1309,7 @@ final private TermRangeQueryNode FieldRangeExpr(CharSequence field) throws Parse break; } default: - jj_la1[25] = jj_gen; + jj_la1[29] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1244,7 +1376,7 @@ final private QueryNode Term(CharSequence field) throws ParseException { break; } default: - jj_la1[26] = jj_gen; + jj_la1[30] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1255,7 +1387,7 @@ final private QueryNode Term(CharSequence field) throws ParseException { break; } default: - jj_la1[27] = jj_gen; + jj_la1[31] = jj_gen; ; } break; @@ -1270,7 +1402,7 @@ final private QueryNode Term(CharSequence field) throws ParseException { break; } default: - jj_la1[28] = jj_gen; + jj_la1[32] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1280,7 +1412,7 @@ final private QueryNode Term(CharSequence field) throws ParseException { break; } default: - jj_la1[29] = jj_gen; + jj_la1[33] = jj_gen; ; } { @@ -1304,7 +1436,7 @@ final private QueryNode QuotedTerm(CharSequence field) throws ParseException { break; } default: - jj_la1[30] = jj_gen; + jj_la1[34] = jj_gen; ; } { @@ -1329,7 +1461,7 @@ final private TermRangeQueryNode TermRangeExpr(CharSequence field) throws ParseE break; } default: - jj_la1[31] = jj_gen; + jj_la1[35] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1347,7 +1479,7 @@ final private TermRangeQueryNode TermRangeExpr(CharSequence field) throws ParseE break; } default: - jj_la1[32] = jj_gen; + jj_la1[36] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1367,7 +1499,7 @@ final private TermRangeQueryNode TermRangeExpr(CharSequence field) throws ParseE break; } default: - jj_la1[33] = jj_gen; + jj_la1[37] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1383,7 +1515,7 @@ final private TermRangeQueryNode TermRangeExpr(CharSequence field) throws ParseE break; } default: - jj_la1[34] = jj_gen; + jj_la1[38] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1796,10 +1928,38 @@ private boolean jj_2_28(int xla) { } } - private boolean jj_3R_17() { + private boolean jj_2_29(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return (!jj_3_29()); + } + catch (LookaheadSuccess ls) { + return true; + } + finally { + jj_save(28, xla); + } + } + + private boolean jj_2_30(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return (!jj_3_30()); + } + catch (LookaheadSuccess ls) { + return true; + } + finally { + jj_save(29, xla); + } + } + + private boolean jj_3R_32() { if (jj_scan_token(FN_PREFIX)) return true; - if (jj_scan_token(UNORDERED_NO_OVERLAPS)) + if (jj_scan_token(NOT_WITHIN)) return true; return false; } @@ -1807,397 +1967,417 @@ private boolean jj_3R_17() { private boolean jj_3R_25() { if (jj_scan_token(FN_PREFIX)) return true; - if (jj_scan_token(CONTAINED_BY)) + if (jj_scan_token(BEFORE)) return true; return false; } - private boolean jj_3R_11() { - if (jj_3R_9()) + private boolean jj_3R_16() { + if (jj_scan_token(FN_PREFIX)) + return true; + if (jj_scan_token(ATLEAST)) return true; + return false; + } + + private boolean jj_3R_12() { Token xsp; xsp = jj_scanpos; - if (jj_scan_token(17)) { + if (jj_3R_38()) { jj_scanpos = xsp; - if (jj_scan_token(18)) { + if (jj_3R_39()) { jj_scanpos = xsp; - if (jj_scan_token(19)) { + if (jj_3R_40()) { jj_scanpos = xsp; - if (jj_scan_token(20)) + if (jj_3R_41()) return true; } } } + xsp = jj_scanpos; + if (jj_3R_42()) + jj_scanpos = xsp; return false; } - private boolean jj_3R_19() { - if (jj_scan_token(FN_PREFIX)) - return true; - if (jj_scan_token(WILDCARD)) + private boolean jj_3R_48() { + if (jj_scan_token(CARAT)) return true; return false; } - private boolean jj_3R_47() { - if (jj_scan_token(TILDE)) + private boolean jj_3_27() { + if (jj_3R_37()) return true; return false; } - private boolean jj_3R_16() { - if (jj_scan_token(FN_PREFIX)) - return true; - if (jj_scan_token(UNORDERED)) + private boolean jj_3_26() { + if (jj_3R_36()) return true; return false; } - private boolean jj_3R_24() { - if (jj_scan_token(FN_PREFIX)) - return true; - if (jj_scan_token(NOT_CONTAINING)) + private boolean jj_3_25() { + if (jj_3R_35()) return true; return false; } - private boolean jj_3R_43() { - if (jj_scan_token(QUOTED)) + private boolean jj_3_24() { + if (jj_3R_34()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_47()) - jj_scanpos = xsp; return false; } - private boolean jj_3R_30() { - if (jj_scan_token(FN_PREFIX)) - return true; - if (jj_scan_token(NON_OVERLAPPING)) + private boolean jj_3_23() { + if (jj_3R_33()) return true; return false; } - private boolean jj_3R_14() { + private boolean jj_3R_26() { if (jj_scan_token(FN_PREFIX)) return true; - if (jj_scan_token(MAXGAPS)) + if (jj_scan_token(PHRASE)) return true; return false; } - private boolean jj_3_28() { - if (jj_scan_token(NUMBER)) - return true; + private boolean jj_3_22() { + if (jj_3R_32()) + return true; return false; } - private boolean jj_3R_23() { + private boolean jj_3R_35() { if (jj_scan_token(FN_PREFIX)) return true; - if (jj_scan_token(CONTAINING)) + if (jj_scan_token(EXTEND)) return true; return false; } - private boolean jj_3R_9() { - if (jj_scan_token(TERM)) + private boolean jj_3_21() { + if (jj_3R_31()) return true; return false; } - private boolean jj_3R_29() { - if (jj_scan_token(FN_PREFIX)) - return true; - if (jj_scan_token(OVERLAPPING)) + private boolean jj_3_20() { + if (jj_3R_30()) return true; return false; } - private boolean jj_3R_41() { - if (jj_3R_45()) - return true; + private boolean jj_3R_44() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(26)) { + jj_scanpos = xsp; + if (jj_scan_token(25)) + return true; + } return false; } - private boolean jj_3R_37() { - if (jj_3R_43()) + private boolean jj_3_19() { + if (jj_3R_29()) return true; return false; } - private boolean jj_3R_45() { - if (jj_scan_token(TILDE)) + private boolean jj_3R_43() { + if (jj_scan_token(QUOTED)) return true; return false; } - private boolean jj_3R_38() { - if (jj_3R_44()) - return true; + private boolean jj_3R_37() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_43()) { + jj_scanpos = xsp; + if (jj_3R_44()) + return true; + } return false; } - private boolean jj_3R_36() { - if (jj_3R_42()) + private boolean jj_3_18() { + if (jj_3R_28()) return true; return false; } - private boolean jj_3_2() { - if (jj_3R_10()) + private boolean jj_3_17() { + if (jj_3R_27()) return true; return false; } - private boolean jj_3R_13() { - if (jj_scan_token(FN_PREFIX)) - return true; - if (jj_scan_token(MAXWIDTH)) + private boolean jj_3_16() { + if (jj_3R_26()) return true; return false; } - private boolean jj_3R_35() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(25)) { - jj_scanpos = xsp; - if (jj_scan_token(24)) - return true; - } - xsp = jj_scanpos; - if (jj_3R_41()) - jj_scanpos = xsp; + private boolean jj_3_15() { + if (jj_3R_25()) + return true; return false; } - private boolean jj_3R_20() { - if (jj_scan_token(FN_PREFIX)) - return true; - if (jj_scan_token(AFTER)) + private boolean jj_3R_11() { + if (jj_scan_token(TERM)) return true; return false; } - private boolean jj_3_1() { - if (jj_3R_9()) + private boolean jj_3_14() { + if (jj_3R_24()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(15)) { - jj_scanpos = xsp; - if (jj_scan_token(16)) - return true; - } return false; } - private boolean jj_3_3() { - if (jj_3R_11()) + private boolean jj_3_13() { + if (jj_3R_23()) return true; return false; } - private boolean jj_3R_34() { - if (jj_scan_token(REGEXPTERM)) + private boolean jj_3_12() { + if (jj_3R_22()) return true; return false; } - private boolean jj_3R_28() { - if (jj_scan_token(FN_PREFIX)) - return true; - if (jj_scan_token(NOT_WITHIN)) + private boolean jj_3_11() { + if (jj_3R_21()) return true; return false; } - private boolean jj_3R_21() { + private boolean jj_3R_22() { if (jj_scan_token(FN_PREFIX)) return true; - if (jj_scan_token(BEFORE)) + if (jj_scan_token(FN_OR)) return true; return false; } - private boolean jj_3R_10() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_34()) { - jj_scanpos = xsp; - if (jj_3R_35()) { - jj_scanpos = xsp; - if (jj_3R_36()) { - jj_scanpos = xsp; - if (jj_3R_37()) - return true; - } - } - } - xsp = jj_scanpos; - if (jj_3R_38()) - jj_scanpos = xsp; + private boolean jj_3_10() { + if (jj_3R_20()) + return true; return false; } - private boolean jj_3R_12() { - if (jj_scan_token(FN_PREFIX)) - return true; - if (jj_scan_token(ATLEAST)) + private boolean jj_3_9() { + if (jj_3R_19()) return true; return false; } - private boolean jj_3R_44() { - if (jj_scan_token(CARAT)) + private boolean jj_3_8() { + if (jj_3R_18()) return true; return false; } - private boolean jj_3_25() { - if (jj_3R_33()) + private boolean jj_3_7() { + if (jj_3R_17()) return true; return false; } - private boolean jj_3_24() { - if (jj_3R_32()) + private boolean jj_3_6() { + if (jj_3R_16()) return true; return false; } - private boolean jj_3_23() { - if (jj_3R_31()) + private boolean jj_3_29() { + if (jj_scan_token(NUMBER)) return true; return false; } - private boolean jj_3_22() { - if (jj_3R_30()) + private boolean jj_3R_31() { + if (jj_scan_token(FN_PREFIX)) + return true; + if (jj_scan_token(WITHIN)) return true; return false; } - private boolean jj_3_21() { - if (jj_3R_29()) + private boolean jj_3_2() { + if (jj_3R_12()) return true; return false; } - private boolean jj_3R_22() { - if (jj_scan_token(FN_PREFIX)) - return true; - if (jj_scan_token(PHRASE)) + private boolean jj_3_28() { + if (jj_scan_token(NUMBER)) return true; return false; } - private boolean jj_3_20() { - if (jj_3R_28()) + private boolean jj_3_1() { + if (jj_3R_11()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(16)) { + jj_scanpos = xsp; + if (jj_scan_token(17)) + return true; + } return false; } - private boolean jj_3R_31() { - if (jj_scan_token(FN_PREFIX)) + private boolean jj_3_3() { + if (jj_3R_13()) return true; - if (jj_scan_token(EXTEND)) + return false; + } + + private boolean jj_3R_50() { + if (jj_scan_token(RANGEIN_START)) return true; return false; } - private boolean jj_3_19() { - if (jj_3R_27()) + private boolean jj_3R_19() { + if (jj_scan_token(FN_PREFIX)) + return true; + if (jj_scan_token(ORDERED)) return true; return false; } - private boolean jj_3_18() { - if (jj_3R_26()) + private boolean jj_3R_36() { + if (jj_scan_token(FN_PREFIX)) + return true; + if (jj_scan_token(FUZZYTERM)) return true; return false; } - private boolean jj_3R_40() { + private boolean jj_3R_46() { Token xsp; xsp = jj_scanpos; - if (jj_scan_token(25)) { + if (jj_3R_50()) { jj_scanpos = xsp; - if (jj_scan_token(24)) + if (jj_scan_token(29)) return true; } + xsp = jj_scanpos; + if (jj_scan_token(58)) { + jj_scanpos = xsp; + if (jj_scan_token(57)) { + jj_scanpos = xsp; + if (jj_scan_token(54)) + return true; + } + } return false; } - private boolean jj_3_17() { - if (jj_3R_25()) + private boolean jj_3R_30() { + if (jj_scan_token(FN_PREFIX)) + return true; + if (jj_scan_token(NOT_CONTAINED_BY)) return true; return false; } - private boolean jj_3R_39() { - if (jj_scan_token(QUOTED)) + private boolean jj_3R_21() { + if (jj_scan_token(FN_PREFIX)) + return true; + if (jj_scan_token(UNORDERED_NO_OVERLAPS)) return true; return false; } - private boolean jj_3R_33() { + private boolean jj_3R_29() { + if (jj_scan_token(FN_PREFIX)) + return true; + if (jj_scan_token(CONTAINED_BY)) + return true; + return false; + } + + private boolean jj_3R_13() { + if (jj_3R_11()) + return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_39()) { + if (jj_scan_token(18)) { jj_scanpos = xsp; - if (jj_3R_40()) - return true; + if (jj_scan_token(19)) { + jj_scanpos = xsp; + if (jj_scan_token(20)) { + jj_scanpos = xsp; + if (jj_scan_token(21)) + return true; + } + } } return false; } - private boolean jj_3_16() { - if (jj_3R_24()) + private boolean jj_3R_23() { + if (jj_scan_token(FN_PREFIX)) return true; - return false; - } - - private boolean jj_3_15() { - if (jj_3R_23()) + if (jj_scan_token(WILDCARD)) return true; return false; } - private boolean jj_3_14() { - if (jj_3R_22()) + private boolean jj_3R_51() { + if (jj_scan_token(TILDE)) return true; return false; } - private boolean jj_3_13() { - if (jj_3R_21()) + private boolean jj_3R_20() { + if (jj_scan_token(FN_PREFIX)) + return true; + if (jj_scan_token(UNORDERED)) return true; return false; } - private boolean jj_3_12() { - if (jj_3R_20()) + private boolean jj_3R_28() { + if (jj_scan_token(FN_PREFIX)) + return true; + if (jj_scan_token(NOT_CONTAINING)) return true; return false; } - private boolean jj_3_11() { - if (jj_3R_19()) + private boolean jj_3R_15() { + if (jj_scan_token(ZL_PREFIX)) + return true; + if (jj_scan_token(TERM_SET)) return true; return false; } - private boolean jj_3_10() { - if (jj_3R_18()) + private boolean jj_3R_47() { + if (jj_scan_token(QUOTED)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_51()) + jj_scanpos = xsp; return false; } - private boolean jj_3_9() { - if (jj_3R_17()) + private boolean jj_3R_34() { + if (jj_scan_token(FN_PREFIX)) + return true; + if (jj_scan_token(NON_OVERLAPPING)) return true; return false; } @@ -2205,107 +2385,115 @@ private boolean jj_3_9() { private boolean jj_3R_18() { if (jj_scan_token(FN_PREFIX)) return true; - if (jj_scan_token(FN_OR)) + if (jj_scan_token(MAXGAPS)) return true; return false; } - private boolean jj_3_8() { - if (jj_3R_16()) + private boolean jj_3_30() { + if (jj_scan_token(NUMBER)) return true; return false; } - private boolean jj_3_7() { - if (jj_3R_15()) + private boolean jj_3R_27() { + if (jj_scan_token(FN_PREFIX)) + return true; + if (jj_scan_token(CONTAINING)) return true; return false; } - private boolean jj_3_6() { - if (jj_3R_14()) + private boolean jj_3R_14() { + if (jj_scan_token(ZL_PREFIX)) + return true; + if (jj_scan_token(NUMERIC_SET)) return true; return false; } - private boolean jj_3_5() { - if (jj_3R_13()) + private boolean jj_3R_33() { + if (jj_scan_token(FN_PREFIX)) + return true; + if (jj_scan_token(OVERLAPPING)) return true; return false; } - private boolean jj_3_4() { - if (jj_3R_12()) + private boolean jj_3R_45() { + if (jj_3R_49()) return true; return false; } - private boolean jj_3_27() { - if (jj_scan_token(NUMBER)) + private boolean jj_3R_41() { + if (jj_3R_47()) return true; return false; } - private boolean jj_3R_27() { - if (jj_scan_token(FN_PREFIX)) + private boolean jj_3R_49() { + if (jj_scan_token(TILDE)) return true; - if (jj_scan_token(WITHIN)) + return false; + } + + private boolean jj_3R_42() { + if (jj_3R_48()) return true; return false; } - private boolean jj_3_26() { - if (jj_scan_token(NUMBER)) + private boolean jj_3R_40() { + if (jj_3R_46()) return true; return false; } - private boolean jj_3R_46() { - if (jj_scan_token(RANGEIN_START)) + private boolean jj_3_5() { + if (jj_3R_15()) return true; return false; } - private boolean jj_3R_15() { + private boolean jj_3R_17() { if (jj_scan_token(FN_PREFIX)) return true; - if (jj_scan_token(ORDERED)) + if (jj_scan_token(MAXWIDTH)) return true; return false; } - private boolean jj_3R_32() { - if (jj_scan_token(FN_PREFIX)) - return true; - if (jj_scan_token(FUZZYTERM)) + private boolean jj_3_4() { + if (jj_3R_14()) return true; return false; } - private boolean jj_3R_42() { + private boolean jj_3R_39() { Token xsp; xsp = jj_scanpos; - if (jj_3R_46()) { + if (jj_scan_token(26)) { jj_scanpos = xsp; - if (jj_scan_token(28)) + if (jj_scan_token(25)) return true; } xsp = jj_scanpos; - if (jj_scan_token(55)) { + if (jj_3R_45()) jj_scanpos = xsp; - if (jj_scan_token(54)) { - jj_scanpos = xsp; - if (jj_scan_token(51)) - return true; - } - } return false; } - private boolean jj_3R_26() { + private boolean jj_3R_24() { if (jj_scan_token(FN_PREFIX)) return true; - if (jj_scan_token(NOT_CONTAINED_BY)) + if (jj_scan_token(AFTER)) + return true; + return false; + } + + private boolean jj_3R_38() { + if (jj_scan_token(REGEXPTERM)) return true; return false; } @@ -2326,7 +2514,7 @@ private boolean jj_3R_26() { private Token jj_scanpos, jj_lastpos; private int jj_la; private int jj_gen; - final private int[] jj_la1 = new int[35]; + final private int[] jj_la1 = new int[39]; static private int[] jj_la1_0; static private int[] jj_la1_1; @@ -2336,17 +2524,17 @@ private boolean jj_3R_26() { } private static void jj_la1_init_0() { - jj_la1_0 = new int[] { 0x3f803c00, 0x200, 0x100, 0x2400, 0x3400, 0x3400, 0x18000, 0x23800800, 0x3f800800, 0x200000, 0x400000, 0x400000, 0x3800800, - 0x3800800, 0x3800800, 0x3800800, 0x3800800, 0x3000000, 0x3800000, 0x1000000, 0x3000000, 0x3800000, 0x3000000, 0x3800000, 0x1e0000, 0x3800000, - 0x3000000, 0x400000, 0x1f800000, 0x200000, 0x400000, 0x18000000, 0x0, 0x0, 0x0, }; + jj_la1_0 = new int[] { 0x7f007c00, 0x200, 0x100, 0x4400, 0x6400, 0x6400, 0x30000, 0x47001800, 0x7f001800, 0x400000, 0x800000, 0x800000, 0x7000000, + 0x7000000, 0x6000000, 0x7000000, 0x7000800, 0x7000800, 0x7000800, 0x7000800, 0x7000800, 0x6000000, 0x7000000, 0x2000000, 0x6000000, 0x7000000, + 0x6000000, 0x7000000, 0x3c0000, 0x7000000, 0x6000000, 0x800000, 0x3f000000, 0x400000, 0x800000, 0x30000000, 0x0, 0x0, 0x0, }; } private static void jj_la1_init_1() { - jj_la1_1 = new int[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1000000, 0x1000000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc80000, 0xc80000, 0x300000, }; + jj_la1_1 = new int[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8000000, 0x8000000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6400000, 0x6400000, 0x1800000, }; } - final private JJCalls[] jj_2_rtns = new JJCalls[28]; + final private JJCalls[] jj_2_rtns = new JJCalls[30]; private boolean jj_rescan = false; private int jj_gc = 0; @@ -2358,7 +2546,7 @@ public ZuliaSyntaxParser(CharStream stream) { token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 35; i++) + for (int i = 0; i < 39; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); @@ -2372,7 +2560,7 @@ public void ReInit(CharStream stream) { token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 35; i++) + for (int i = 0; i < 39; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); @@ -2386,7 +2574,7 @@ public ZuliaSyntaxParser(ZuliaSyntaxParserTokenManager tm) { token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 35; i++) + for (int i = 0; i < 39; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); @@ -2400,7 +2588,7 @@ public void ReInit(ZuliaSyntaxParserTokenManager tm) { token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 35; i++) + for (int i = 0; i < 39; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); @@ -2553,12 +2741,12 @@ else if (jj_endpos != 0) { */ public ParseException generateParseException() { jj_expentries.clear(); - boolean[] la1tokens = new boolean[57]; + boolean[] la1tokens = new boolean[60]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } - for (int i = 0; i < 35; i++) { + for (int i = 0; i < 39; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1 << j)) != 0) { @@ -2570,7 +2758,7 @@ public ParseException generateParseException() { } } } - for (int i = 0; i < 57; i++) { + for (int i = 0; i < 60; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; @@ -2611,7 +2799,7 @@ final public void disable_tracing() { private void jj_rescan_token() { jj_rescan = true; - for (int i = 0; i < 28; i++) { + for (int i = 0; i < 30; i++) { try { JJCalls p = jj_2_rtns[i]; @@ -2704,6 +2892,12 @@ private void jj_rescan_token() { case 27: jj_3_28(); break; + case 28: + jj_3_29(); + break; + case 29: + jj_3_30(); + break; } } p = p.next; diff --git a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/parser/ZuliaSyntaxParser.jj b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/parser/ZuliaSyntaxParser.jj index ea722a0d..e41ed6fe 100644 --- a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/parser/ZuliaSyntaxParser.jj +++ b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/parser/ZuliaSyntaxParser.jj @@ -80,6 +80,9 @@ import org.apache.lucene.queryparser.flexible.standard.nodes.RegexpQueryNode; import org.apache.lucene.queryparser.charstream.CharStream; import org.apache.lucene.queryparser.charstream.FastCharStream; import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode; +import io.zulia.server.search.queryparser.node.ZuliaNumericSetQueryNode; +import io.zulia.server.search.queryparser.node.ZuliaTermsInSetQueryNode; +import io.zulia.server.search.queryparser.node.ZuliaFieldableQueryNode; import static io.zulia.server.search.queryparser.parser.EscapeQuerySyntaxImpl.discardEscapeChar; @@ -137,7 +140,7 @@ PARSER_END(ZuliaSyntaxParser) | <#_QUOTED_CHAR: ( ~[ "\"", "\\" ] | <_ESCAPED_CHAR> ) > } - SKIP : { + SKIP : { < <_WHITESPACE> > } @@ -146,6 +149,7 @@ PARSER_END(ZuliaSyntaxParser) | | | : Function + | : Zulia | | | @@ -165,10 +169,15 @@ PARSER_END(ZuliaSyntaxParser) | : Range } - TOKEN : { + TOKEN : { : DEFAULT } + TOKEN : { + + | +} + TOKEN : { | @@ -327,7 +336,7 @@ private QueryNode Clause(CharSequence field) : { ( LOOKAHEAD(2) q = FieldRangeExpr(field) | (LOOKAHEAD(2) field = FieldName() ( | ))? - (LOOKAHEAD(2) q = Term(field) | q = GroupingExpr(field) | q = IntervalExpr(field)) + (LOOKAHEAD(2) q = Term(field) | q = GroupingExpr(field) | q = IntervalExpr(field) | q = ZuliaExpr(field)) ) { return q; @@ -368,6 +377,47 @@ private QueryNode GroupingExpr(CharSequence field) : { } +private ZuliaFieldableQueryNode ZuliaExpr(CharSequence field) : { + ZuliaFieldableQueryNode source; +} + { + LOOKAHEAD(2) source = NumericsSetQuery(field) { return source; } | + LOOKAHEAD(2) source = TermsInSetQuery(field) { return source; } + } + +private ZuliaNumericSetQueryNode NumericsSetQuery(CharSequence field) : { + CharSequence value; + ArrayList values = new ArrayList(); +} +{ + + (value = TermText() { values.add(value); })+ + { + return new ZuliaNumericSetQueryNode(field, values); + } +} + + +private ZuliaTermsInSetQueryNode TermsInSetQuery(CharSequence field) : { + CharSequence value; + ArrayList values = new ArrayList(); +} +{ + + (value = TermText() { values.add(value); })+ + { + return new ZuliaTermsInSetQueryNode(field, values); + } +} + +private CharSequence TermText() : { +} +{ + () { return token.image.substring(1, token.image.length() - 1); } + | ( | ) { return token.image; } +} + + /** * An interval expression (functions) node. */ diff --git a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/parser/ZuliaSyntaxParserConstants.java b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/parser/ZuliaSyntaxParserConstants.java index 48470ec2..12c6b6d1 100644 --- a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/parser/ZuliaSyntaxParserConstants.java +++ b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/parser/ZuliaSyntaxParserConstants.java @@ -54,201 +54,217 @@ public interface ZuliaSyntaxParserConstants { /** * RegularExpression Id. */ - int PLUS = 12; + int ZL_PREFIX = 12; /** * RegularExpression Id. */ - int MINUS = 13; + int PLUS = 13; /** * RegularExpression Id. */ - int RPAREN = 14; + int MINUS = 14; /** * RegularExpression Id. */ - int OP_COLON = 15; + int RPAREN = 15; /** * RegularExpression Id. */ - int OP_EQUAL = 16; + int OP_COLON = 16; /** * RegularExpression Id. */ - int OP_LESSTHAN = 17; + int OP_EQUAL = 17; /** * RegularExpression Id. */ - int OP_LESSTHANEQ = 18; + int OP_LESSTHAN = 18; /** * RegularExpression Id. */ - int OP_MORETHAN = 19; + int OP_LESSTHANEQ = 19; /** * RegularExpression Id. */ - int OP_MORETHANEQ = 20; + int OP_MORETHAN = 20; /** * RegularExpression Id. */ - int CARAT = 21; + int OP_MORETHANEQ = 21; /** * RegularExpression Id. */ - int TILDE = 22; + int CARAT = 22; /** * RegularExpression Id. */ - int QUOTED = 23; + int TILDE = 23; /** * RegularExpression Id. */ - int NUMBER = 24; + int QUOTED = 24; /** * RegularExpression Id. */ - int TERM = 25; + int NUMBER = 25; /** * RegularExpression Id. */ - int REGEXPTERM = 26; + int TERM = 26; /** * RegularExpression Id. */ - int RANGEIN_START = 27; + int REGEXPTERM = 27; /** * RegularExpression Id. */ - int RANGEEX_START = 28; + int RANGEIN_START = 28; /** * RegularExpression Id. */ - int LPAREN = 29; + int RANGEEX_START = 29; /** * RegularExpression Id. */ - int ATLEAST = 30; + int LPAREN = 30; /** * RegularExpression Id. */ - int AFTER = 31; + int NUMERIC_SET = 31; /** * RegularExpression Id. */ - int BEFORE = 32; + int TERM_SET = 32; /** * RegularExpression Id. */ - int CONTAINED_BY = 33; + int ATLEAST = 33; /** * RegularExpression Id. */ - int CONTAINING = 34; + int AFTER = 34; /** * RegularExpression Id. */ - int EXTEND = 35; + int BEFORE = 35; /** * RegularExpression Id. */ - int FN_OR = 36; + int CONTAINED_BY = 36; /** * RegularExpression Id. */ - int FUZZYTERM = 37; + int CONTAINING = 37; /** * RegularExpression Id. */ - int MAXGAPS = 38; + int EXTEND = 38; /** * RegularExpression Id. */ - int MAXWIDTH = 39; + int FN_OR = 39; /** * RegularExpression Id. */ - int NON_OVERLAPPING = 40; + int FUZZYTERM = 40; /** * RegularExpression Id. */ - int NOT_CONTAINED_BY = 41; + int MAXGAPS = 41; /** * RegularExpression Id. */ - int NOT_CONTAINING = 42; + int MAXWIDTH = 42; /** * RegularExpression Id. */ - int NOT_WITHIN = 43; + int NON_OVERLAPPING = 43; /** * RegularExpression Id. */ - int ORDERED = 44; + int NOT_CONTAINED_BY = 44; /** * RegularExpression Id. */ - int OVERLAPPING = 45; + int NOT_CONTAINING = 45; /** * RegularExpression Id. */ - int PHRASE = 46; + int NOT_WITHIN = 46; /** * RegularExpression Id. */ - int UNORDERED = 47; + int ORDERED = 47; /** * RegularExpression Id. */ - int UNORDERED_NO_OVERLAPS = 48; + int OVERLAPPING = 48; /** * RegularExpression Id. */ - int WILDCARD = 49; + int PHRASE = 49; /** * RegularExpression Id. */ - int WITHIN = 50; + int UNORDERED = 50; /** * RegularExpression Id. */ - int RANGE_TO = 51; + int UNORDERED_NO_OVERLAPS = 51; /** * RegularExpression Id. */ - int RANGEIN_END = 52; + int WILDCARD = 52; /** * RegularExpression Id. */ - int RANGEEX_END = 53; + int WITHIN = 53; /** * RegularExpression Id. */ - int RANGE_QUOTED = 54; + int RANGE_TO = 54; /** * RegularExpression Id. */ - int RANGE_GOOP = 55; + int RANGEIN_END = 55; + /** + * RegularExpression Id. + */ + int RANGEEX_END = 56; + /** + * RegularExpression Id. + */ + int RANGE_QUOTED = 57; + /** + * RegularExpression Id. + */ + int RANGE_GOOP = 58; /** * Lexical state. */ - int Function = 0; + int Zulia = 0; + /** + * Lexical state. + */ + int Function = 1; /** * Lexical state. */ - int Range = 1; + int Range = 2; /** * Lexical state. */ - int DEFAULT = 2; + int DEFAULT = 3; /** * Literal token values. */ String[] tokenImage = { "", "<_NUM_CHAR>", "<_ESCAPED_CHAR>", "<_TERM_START_CHAR>", "<_TERM_CHAR>", "<_WHITESPACE>", "<_QUOTED_CHAR>", - "", "", "", "", "\"fn:\"", "\"+\"", "\"-\"", "\")\"", "\":\"", "\"=\"", "\"<\"", "\"<=\"", "\">\"", "\">=\"", - "\"^\"", "\"~\"", "", "", "", "", "\"[\"", "\"{\"", "\"(\"", "", "\"after\"", "\"before\"", - "", "\"containing\"", "\"extend\"", "\"or\"", "", "", "", "", "", - "", "", "\"ordered\"", "\"overlapping\"", "\"phrase\"", "\"unordered\"", "", "\"wildcard\"", - "\"within\"", "\"TO\"", "\"]\"", "\"}\"", "", "", "\"@\"", }; + "", "", "", "", "\"fn:\"", "\"zl:\"", "\"+\"", "\"-\"", "\")\"", "\":\"", "\"=\"", "\"<\"", "\"<=\"", "\">\"", + "\">=\"", "\"^\"", "\"~\"", "", "", "", "", "\"[\"", "\"{\"", "\"(\"", "", "", "", + "\"after\"", "\"before\"", "", "\"containing\"", "\"extend\"", "\"or\"", "", "", "", + "", "", "", "", "\"ordered\"", "\"overlapping\"", "\"phrase\"", "\"unordered\"", + "", "\"wildcard\"", "\"within\"", "\"TO\"", "\"]\"", "\"}\"", "", "", "\"@\"", }; } diff --git a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/parser/ZuliaSyntaxParserTokenManager.java b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/parser/ZuliaSyntaxParserTokenManager.java index cca91b23..ac3aa594 100644 --- a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/parser/ZuliaSyntaxParserTokenManager.java +++ b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/parser/ZuliaSyntaxParserTokenManager.java @@ -23,7 +23,6 @@ /** * Token Manager. */ -@SuppressWarnings("ALL") public class ZuliaSyntaxParserTokenManager implements ZuliaSyntaxParserConstants { /** Debug output. */ @@ -33,17 +32,17 @@ public class ZuliaSyntaxParserTokenManager implements ZuliaSyntaxParserConstants * Set debug output. */ // (setDebugStream omitted). - private final int jjStopStringLiteralDfa_2(int pos, long active0) { + private final int jjStopStringLiteralDfa_3(int pos, long active0) { switch (pos) { case 0: - if ((active0 & 0x800L) != 0L) { - jjmatchedKind = 25; + if ((active0 & 0x1800L) != 0L) { + jjmatchedKind = 26; return 32; } return -1; case 1: - if ((active0 & 0x800L) != 0L) { - jjmatchedKind = 25; + if ((active0 & 0x1800L) != 0L) { + jjmatchedKind = 26; jjmatchedPos = 1; return 32; } @@ -53,8 +52,8 @@ private final int jjStopStringLiteralDfa_2(int pos, long active0) { } } - private final int jjStartNfa_2(int pos, long active0) { - return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1); + private final int jjStartNfa_3(int pos, long active0) { + return jjMoveNfa_3(jjStopStringLiteralDfa_3(pos, active0), pos + 1); } private int jjStopAtPos(int pos, int kind) { @@ -63,85 +62,91 @@ private int jjStopAtPos(int pos, int kind) { return pos + 1; } - private int jjMoveStringLiteralDfa0_2() { + private int jjMoveStringLiteralDfa0_3() { switch (curChar) { case 40: - return jjStopAtPos(0, 29); + return jjStopAtPos(0, 30); case 41: - return jjStopAtPos(0, 14); + return jjStopAtPos(0, 15); case 43: - return jjStopAtPos(0, 12); - case 45: return jjStopAtPos(0, 13); + case 45: + return jjStopAtPos(0, 14); case 58: - return jjStopAtPos(0, 15); + return jjStopAtPos(0, 16); case 60: - jjmatchedKind = 17; - return jjMoveStringLiteralDfa1_2(0x40000L); + jjmatchedKind = 18; + return jjMoveStringLiteralDfa1_3(0x80000L); case 61: - return jjStopAtPos(0, 16); + return jjStopAtPos(0, 17); case 62: - jjmatchedKind = 19; - return jjMoveStringLiteralDfa1_2(0x100000L); + jjmatchedKind = 20; + return jjMoveStringLiteralDfa1_3(0x200000L); case 64: - return jjStopAtPos(0, 56); + return jjStopAtPos(0, 59); case 91: - return jjStopAtPos(0, 27); + return jjStopAtPos(0, 28); case 94: - return jjStopAtPos(0, 21); + return jjStopAtPos(0, 22); case 102: - return jjMoveStringLiteralDfa1_2(0x800L); + return jjMoveStringLiteralDfa1_3(0x800L); + case 122: + return jjMoveStringLiteralDfa1_3(0x1000L); case 123: - return jjStopAtPos(0, 28); + return jjStopAtPos(0, 29); case 126: - return jjStopAtPos(0, 22); + return jjStopAtPos(0, 23); default: - return jjMoveNfa_2(0, 0); + return jjMoveNfa_3(0, 0); } } - private int jjMoveStringLiteralDfa1_2(long active0) { + private int jjMoveStringLiteralDfa1_3(long active0) { try { curChar = input_stream.readChar(); } catch (java.io.IOException e) { - jjStopStringLiteralDfa_2(0, active0); + jjStopStringLiteralDfa_3(0, active0); return 1; } switch (curChar) { case 61: - if ((active0 & 0x40000L) != 0L) - return jjStopAtPos(1, 18); - else if ((active0 & 0x100000L) != 0L) - return jjStopAtPos(1, 20); + if ((active0 & 0x80000L) != 0L) + return jjStopAtPos(1, 19); + else if ((active0 & 0x200000L) != 0L) + return jjStopAtPos(1, 21); break; + case 108: + return jjMoveStringLiteralDfa2_3(active0, 0x1000L); case 110: - return jjMoveStringLiteralDfa2_2(active0, 0x800L); + return jjMoveStringLiteralDfa2_3(active0, 0x800L); default: break; } - return jjStartNfa_2(0, active0); + return jjStartNfa_3(0, active0); } - private int jjMoveStringLiteralDfa2_2(long old0, long active0) { + private int jjMoveStringLiteralDfa2_3(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_2(0, old0); + return jjStartNfa_3(0, old0); try { curChar = input_stream.readChar(); } catch (java.io.IOException e) { - jjStopStringLiteralDfa_2(1, active0); + jjStopStringLiteralDfa_3(1, active0); return 2; } switch (curChar) { case 58: if ((active0 & 0x800L) != 0L) return jjStopAtPos(2, 11); + else if ((active0 & 0x1000L) != 0L) + return jjStopAtPos(2, 12); break; default: break; } - return jjStartNfa_2(1, active0); + return jjStartNfa_3(1, active0); } static final long[] jjbitVec0 = { 0x1L, 0x0L, 0x0L, 0x0L }; @@ -149,7 +154,7 @@ private int jjMoveStringLiteralDfa2_2(long old0, long active0) { static final long[] jjbitVec3 = { 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL }; static final long[] jjbitVec4 = { 0xfffefffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL }; - private int jjMoveNfa_2(int startState, int curPos) { + private int jjMoveNfa_3(int startState, int curPos) { int startsAt = 0; jjnewStateCnt = 32; int i = 1; @@ -166,16 +171,16 @@ private int jjMoveNfa_2(int startState, int curPos) { case 23: if ((0x8bff7cf8ffffd9ffL & l) == 0L) break; - if (kind > 25) - kind = 25; + if (kind > 26) + kind = 26; { jjCheckNAddTwoStates(23, 24); } break; case 0: if ((0x8bff54f8ffffd9ffL & l) != 0L) { - if (kind > 25) - kind = 25; + if (kind > 26) + kind = 26; { jjCheckNAddTwoStates(23, 24); } @@ -195,8 +200,8 @@ else if (curChar == 33) { kind = 10; } if ((0x3ff000000000000L & l) != 0L) { - if (kind > 24) - kind = 24; + if (kind > 25) + kind = 25; { jjCheckNAddTwoStates(19, 20); } @@ -231,14 +236,14 @@ else if (curChar == 38) } break; case 18: - if (curChar == 34 && kind > 23) - kind = 23; + if (curChar == 34 && kind > 24) + kind = 24; break; case 19: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 24) - kind = 24; + if (kind > 25) + kind = 25; { jjCheckNAddTwoStates(19, 20); } @@ -251,8 +256,8 @@ else if (curChar == 38) case 21: if ((0x3ff000000000000L & l) == 0L) break; - if (kind > 24) - kind = 24; + if (kind > 25) + kind = 25; { jjCheckNAdd(21); } @@ -260,15 +265,15 @@ else if (curChar == 38) case 22: if ((0x8bff54f8ffffd9ffL & l) == 0L) break; - if (kind > 25) - kind = 25; + if (kind > 26) + kind = 26; { jjCheckNAddTwoStates(23, 24); } break; case 25: - if (kind > 25) - kind = 25; + if (kind > 26) + kind = 26; { jjCheckNAddTwoStates(23, 24); } @@ -285,8 +290,8 @@ else if (curChar == 38) } break; case 31: - if (curChar == 47 && kind > 26) - kind = 26; + if (curChar == 47 && kind > 27) + kind = 27; break; default: break; @@ -300,8 +305,8 @@ else if (curChar < 128) { switch (jjstateSet[--i]) { case 32: if ((0x97ffffff87fffffeL & l) != 0L) { - if (kind > 25) - kind = 25; + if (kind > 26) + kind = 26; { jjCheckNAddTwoStates(23, 24); } @@ -312,8 +317,8 @@ else if (curChar == 92) { break; case 0: if ((0x97ffffff87fffffeL & l) != 0L) { - if (kind > 25) - kind = 25; + if (kind > 26) + kind = 26; { jjCheckNAddTwoStates(23, 24); } @@ -386,8 +391,8 @@ else if (curChar == 65) case 22: if ((0x97ffffff87fffffeL & l) == 0L) break; - if (kind > 25) - kind = 25; + if (kind > 26) + kind = 26; { jjCheckNAddTwoStates(23, 24); } @@ -395,8 +400,8 @@ else if (curChar == 65) case 23: if ((0x97ffffff87fffffeL & l) == 0L) break; - if (kind > 25) - kind = 25; + if (kind > 26) + kind = 26; { jjCheckNAddTwoStates(23, 24); } @@ -407,8 +412,8 @@ else if (curChar == 65) } break; case 25: - if (kind > 25) - kind = 25; + if (kind > 26) + kind = 26; { jjCheckNAddTwoStates(23, 24); } @@ -444,8 +449,8 @@ else if (curChar == 65) case 23: if (!jjCanMove_2(hiByte, i1, i2, l1, l2)) break; - if (kind > 25) - kind = 25; + if (kind > 26) + kind = 26; { jjCheckNAddTwoStates(23, 24); } @@ -456,8 +461,8 @@ else if (curChar == 65) kind = 7; } if (jjCanMove_2(hiByte, i1, i2, l1, l2)) { - if (kind > 25) - kind = 25; + if (kind > 26) + kind = 26; { jjCheckNAddTwoStates(23, 24); } @@ -472,8 +477,8 @@ else if (curChar == 65) case 22: if (!jjCanMove_2(hiByte, i1, i2, l1, l2)) break; - if (kind > 25) - kind = 25; + if (kind > 26) + kind = 26; { jjCheckNAddTwoStates(23, 24); } @@ -481,8 +486,8 @@ else if (curChar == 65) case 25: if (!jjCanMove_1(hiByte, i1, i2, l1, l2)) break; - if (kind > 25) - kind = 25; + if (kind > 26) + kind = 26; { jjCheckNAddTwoStates(23, 24); } @@ -518,58 +523,58 @@ else if (curChar == 65) } } - private final int jjStopStringLiteralDfa_0(int pos, long active0) { + private final int jjStopStringLiteralDfa_1(int pos, long active0) { switch (pos) { case 0: - if ((active0 & 0x800000000000L) != 0L) + if ((active0 & 0x4000000000000L) != 0L) return 19; - if ((active0 & 0x80000000L) != 0L) - return 79; if ((active0 & 0x400000000L) != 0L) + return 79; + if ((active0 & 0x2000000000L) != 0L) return 63; return -1; case 1: - if ((active0 & 0x400000000L) != 0L) + if ((active0 & 0x2000000000L) != 0L) return 62; - if ((active0 & 0x800000000000L) != 0L) + if ((active0 & 0x4000000000000L) != 0L) return 18; return -1; case 2: - if ((active0 & 0x800000000000L) != 0L) + if ((active0 & 0x4000000000000L) != 0L) return 17; - if ((active0 & 0x400000000L) != 0L) + if ((active0 & 0x2000000000L) != 0L) return 61; return -1; case 3: - if ((active0 & 0x400000000L) != 0L) + if ((active0 & 0x2000000000L) != 0L) return 60; - if ((active0 & 0x800000000000L) != 0L) + if ((active0 & 0x4000000000000L) != 0L) return 16; return -1; case 4: - if ((active0 & 0x800000000000L) != 0L) + if ((active0 & 0x4000000000000L) != 0L) return 15; - if ((active0 & 0x400000000L) != 0L) + if ((active0 & 0x2000000000L) != 0L) return 59; return -1; case 5: - if ((active0 & 0x400000000L) != 0L) + if ((active0 & 0x2000000000L) != 0L) return 58; - if ((active0 & 0x800000000000L) != 0L) + if ((active0 & 0x4000000000000L) != 0L) return 14; return -1; case 6: - if ((active0 & 0x800000000000L) != 0L) + if ((active0 & 0x4000000000000L) != 0L) return 13; - if ((active0 & 0x400000000L) != 0L) + if ((active0 & 0x2000000000L) != 0L) return 57; return -1; case 7: - if ((active0 & 0x800000000000L) != 0L) + if ((active0 & 0x4000000000000L) != 0L) return 12; return -1; case 8: - if ((active0 & 0x800000000000L) != 0L) + if ((active0 & 0x4000000000000L) != 0L) return 11; return -1; default: @@ -577,330 +582,330 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0) { } } - private final int jjStartNfa_0(int pos, long active0) { - return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); + private final int jjStartNfa_1(int pos, long active0) { + return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1); } - private int jjMoveStringLiteralDfa0_0() { + private int jjMoveStringLiteralDfa0_1() { switch (curChar) { case 40: - return jjStopAtPos(0, 29); + return jjStopAtPos(0, 30); case 97: - return jjMoveStringLiteralDfa1_0(0x80000000L); + return jjMoveStringLiteralDfa1_1(0x400000000L); case 98: - return jjMoveStringLiteralDfa1_0(0x100000000L); + return jjMoveStringLiteralDfa1_1(0x800000000L); case 99: - return jjMoveStringLiteralDfa1_0(0x400000000L); + return jjMoveStringLiteralDfa1_1(0x2000000000L); case 101: - return jjMoveStringLiteralDfa1_0(0x800000000L); + return jjMoveStringLiteralDfa1_1(0x4000000000L); case 111: - return jjMoveStringLiteralDfa1_0(0x301000000000L); + return jjMoveStringLiteralDfa1_1(0x1808000000000L); case 112: - return jjMoveStringLiteralDfa1_0(0x400000000000L); + return jjMoveStringLiteralDfa1_1(0x2000000000000L); case 117: - return jjMoveStringLiteralDfa1_0(0x800000000000L); + return jjMoveStringLiteralDfa1_1(0x4000000000000L); case 119: - return jjMoveStringLiteralDfa1_0(0x6000000000000L); + return jjMoveStringLiteralDfa1_1(0x30000000000000L); default: - return jjMoveNfa_0(0, 0); + return jjMoveNfa_1(0, 0); } } - private int jjMoveStringLiteralDfa1_0(long active0) { + private int jjMoveStringLiteralDfa1_1(long active0) { try { curChar = input_stream.readChar(); } catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(0, active0); + jjStopStringLiteralDfa_1(0, active0); return 1; } switch (curChar) { case 101: - return jjMoveStringLiteralDfa2_0(active0, 0x100000000L); + return jjMoveStringLiteralDfa2_1(active0, 0x800000000L); case 102: - return jjMoveStringLiteralDfa2_0(active0, 0x80000000L); + return jjMoveStringLiteralDfa2_1(active0, 0x400000000L); case 104: - return jjMoveStringLiteralDfa2_0(active0, 0x400000000000L); + return jjMoveStringLiteralDfa2_1(active0, 0x2000000000000L); case 105: - return jjMoveStringLiteralDfa2_0(active0, 0x6000000000000L); + return jjMoveStringLiteralDfa2_1(active0, 0x30000000000000L); case 110: - return jjMoveStringLiteralDfa2_0(active0, 0x800000000000L); + return jjMoveStringLiteralDfa2_1(active0, 0x4000000000000L); case 111: - return jjMoveStringLiteralDfa2_0(active0, 0x400000000L); + return jjMoveStringLiteralDfa2_1(active0, 0x2000000000L); case 114: - if ((active0 & 0x1000000000L) != 0L) { - jjmatchedKind = 36; + if ((active0 & 0x8000000000L) != 0L) { + jjmatchedKind = 39; jjmatchedPos = 1; } - return jjMoveStringLiteralDfa2_0(active0, 0x100000000000L); + return jjMoveStringLiteralDfa2_1(active0, 0x800000000000L); case 118: - return jjMoveStringLiteralDfa2_0(active0, 0x200000000000L); + return jjMoveStringLiteralDfa2_1(active0, 0x1000000000000L); case 120: - return jjMoveStringLiteralDfa2_0(active0, 0x800000000L); + return jjMoveStringLiteralDfa2_1(active0, 0x4000000000L); default: break; } - return jjStartNfa_0(0, active0); + return jjStartNfa_1(0, active0); } - private int jjMoveStringLiteralDfa2_0(long old0, long active0) { + private int jjMoveStringLiteralDfa2_1(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(0, old0); + return jjStartNfa_1(0, old0); try { curChar = input_stream.readChar(); } catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(1, active0); + jjStopStringLiteralDfa_1(1, active0); return 2; } switch (curChar) { case 100: - return jjMoveStringLiteralDfa3_0(active0, 0x100000000000L); + return jjMoveStringLiteralDfa3_1(active0, 0x800000000000L); case 101: - return jjMoveStringLiteralDfa3_0(active0, 0x200000000000L); + return jjMoveStringLiteralDfa3_1(active0, 0x1000000000000L); case 102: - return jjMoveStringLiteralDfa3_0(active0, 0x100000000L); + return jjMoveStringLiteralDfa3_1(active0, 0x800000000L); case 108: - return jjMoveStringLiteralDfa3_0(active0, 0x2000000000000L); + return jjMoveStringLiteralDfa3_1(active0, 0x10000000000000L); case 110: - return jjMoveStringLiteralDfa3_0(active0, 0x400000000L); + return jjMoveStringLiteralDfa3_1(active0, 0x2000000000L); case 111: - return jjMoveStringLiteralDfa3_0(active0, 0x800000000000L); + return jjMoveStringLiteralDfa3_1(active0, 0x4000000000000L); case 114: - return jjMoveStringLiteralDfa3_0(active0, 0x400000000000L); + return jjMoveStringLiteralDfa3_1(active0, 0x2000000000000L); case 116: - return jjMoveStringLiteralDfa3_0(active0, 0x4000880000000L); + return jjMoveStringLiteralDfa3_1(active0, 0x20004400000000L); default: break; } - return jjStartNfa_0(1, active0); + return jjStartNfa_1(1, active0); } - private int jjMoveStringLiteralDfa3_0(long old0, long active0) { + private int jjMoveStringLiteralDfa3_1(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(1, old0); + return jjStartNfa_1(1, old0); try { curChar = input_stream.readChar(); } catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(2, active0); + jjStopStringLiteralDfa_1(2, active0); return 3; } switch (curChar) { case 97: - return jjMoveStringLiteralDfa4_0(active0, 0x400000000000L); + return jjMoveStringLiteralDfa4_1(active0, 0x2000000000000L); case 100: - return jjMoveStringLiteralDfa4_0(active0, 0x2000000000000L); + return jjMoveStringLiteralDfa4_1(active0, 0x10000000000000L); case 101: - return jjMoveStringLiteralDfa4_0(active0, 0x100880000000L); + return jjMoveStringLiteralDfa4_1(active0, 0x804400000000L); case 104: - return jjMoveStringLiteralDfa4_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa4_1(active0, 0x20000000000000L); case 111: - return jjMoveStringLiteralDfa4_0(active0, 0x100000000L); + return jjMoveStringLiteralDfa4_1(active0, 0x800000000L); case 114: - return jjMoveStringLiteralDfa4_0(active0, 0xa00000000000L); + return jjMoveStringLiteralDfa4_1(active0, 0x5000000000000L); case 116: - return jjMoveStringLiteralDfa4_0(active0, 0x400000000L); + return jjMoveStringLiteralDfa4_1(active0, 0x2000000000L); default: break; } - return jjStartNfa_0(2, active0); + return jjStartNfa_1(2, active0); } - private int jjMoveStringLiteralDfa4_0(long old0, long active0) { + private int jjMoveStringLiteralDfa4_1(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(2, old0); + return jjStartNfa_1(2, old0); try { curChar = input_stream.readChar(); } catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(3, active0); + jjStopStringLiteralDfa_1(3, active0); return 4; } switch (curChar) { case 97: - return jjMoveStringLiteralDfa5_0(active0, 0x400000000L); + return jjMoveStringLiteralDfa5_1(active0, 0x2000000000L); case 99: - return jjMoveStringLiteralDfa5_0(active0, 0x2000000000000L); + return jjMoveStringLiteralDfa5_1(active0, 0x10000000000000L); case 100: - return jjMoveStringLiteralDfa5_0(active0, 0x800000000000L); + return jjMoveStringLiteralDfa5_1(active0, 0x4000000000000L); case 105: - return jjMoveStringLiteralDfa5_0(active0, 0x4000000000000L); + return jjMoveStringLiteralDfa5_1(active0, 0x20000000000000L); case 108: - return jjMoveStringLiteralDfa5_0(active0, 0x200000000000L); + return jjMoveStringLiteralDfa5_1(active0, 0x1000000000000L); case 110: - return jjMoveStringLiteralDfa5_0(active0, 0x800000000L); + return jjMoveStringLiteralDfa5_1(active0, 0x4000000000L); case 114: - if ((active0 & 0x80000000L) != 0L) - return jjStopAtPos(4, 31); - return jjMoveStringLiteralDfa5_0(active0, 0x100100000000L); + if ((active0 & 0x400000000L) != 0L) + return jjStopAtPos(4, 34); + return jjMoveStringLiteralDfa5_1(active0, 0x800800000000L); case 115: - return jjMoveStringLiteralDfa5_0(active0, 0x400000000000L); + return jjMoveStringLiteralDfa5_1(active0, 0x2000000000000L); default: break; } - return jjStartNfa_0(3, active0); + return jjStartNfa_1(3, active0); } - private int jjMoveStringLiteralDfa5_0(long old0, long active0) { + private int jjMoveStringLiteralDfa5_1(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(3, old0); + return jjStartNfa_1(3, old0); try { curChar = input_stream.readChar(); } catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(4, active0); + jjStopStringLiteralDfa_1(4, active0); return 5; } switch (curChar) { case 97: - return jjMoveStringLiteralDfa6_0(active0, 0x2200000000000L); + return jjMoveStringLiteralDfa6_1(active0, 0x11000000000000L); case 100: - if ((active0 & 0x800000000L) != 0L) - return jjStopAtPos(5, 35); + if ((active0 & 0x4000000000L) != 0L) + return jjStopAtPos(5, 38); break; case 101: - if ((active0 & 0x100000000L) != 0L) - return jjStopAtPos(5, 32); - else if ((active0 & 0x400000000000L) != 0L) - return jjStopAtPos(5, 46); - return jjMoveStringLiteralDfa6_0(active0, 0x900000000000L); + if ((active0 & 0x800000000L) != 0L) + return jjStopAtPos(5, 35); + else if ((active0 & 0x2000000000000L) != 0L) + return jjStopAtPos(5, 49); + return jjMoveStringLiteralDfa6_1(active0, 0x4800000000000L); case 105: - return jjMoveStringLiteralDfa6_0(active0, 0x400000000L); + return jjMoveStringLiteralDfa6_1(active0, 0x2000000000L); case 110: - if ((active0 & 0x4000000000000L) != 0L) - return jjStopAtPos(5, 50); + if ((active0 & 0x20000000000000L) != 0L) + return jjStopAtPos(5, 53); break; default: break; } - return jjStartNfa_0(4, active0); + return jjStartNfa_1(4, active0); } - private int jjMoveStringLiteralDfa6_0(long old0, long active0) { + private int jjMoveStringLiteralDfa6_1(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(4, old0); + return jjStartNfa_1(4, old0); try { curChar = input_stream.readChar(); } catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(5, active0); + jjStopStringLiteralDfa_1(5, active0); return 6; } switch (curChar) { case 100: - if ((active0 & 0x100000000000L) != 0L) - return jjStopAtPos(6, 44); + if ((active0 & 0x800000000000L) != 0L) + return jjStopAtPos(6, 47); break; case 110: - return jjMoveStringLiteralDfa7_0(active0, 0x400000000L); + return jjMoveStringLiteralDfa7_1(active0, 0x2000000000L); case 112: - return jjMoveStringLiteralDfa7_0(active0, 0x200000000000L); + return jjMoveStringLiteralDfa7_1(active0, 0x1000000000000L); case 114: - return jjMoveStringLiteralDfa7_0(active0, 0x2800000000000L); + return jjMoveStringLiteralDfa7_1(active0, 0x14000000000000L); default: break; } - return jjStartNfa_0(5, active0); + return jjStartNfa_1(5, active0); } - private int jjMoveStringLiteralDfa7_0(long old0, long active0) { + private int jjMoveStringLiteralDfa7_1(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(5, old0); + return jjStartNfa_1(5, old0); try { curChar = input_stream.readChar(); } catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(6, active0); + jjStopStringLiteralDfa_1(6, active0); return 7; } switch (curChar) { case 100: - if ((active0 & 0x2000000000000L) != 0L) - return jjStopAtPos(7, 49); + if ((active0 & 0x10000000000000L) != 0L) + return jjStopAtPos(7, 52); break; case 101: - return jjMoveStringLiteralDfa8_0(active0, 0x800000000000L); + return jjMoveStringLiteralDfa8_1(active0, 0x4000000000000L); case 105: - return jjMoveStringLiteralDfa8_0(active0, 0x400000000L); + return jjMoveStringLiteralDfa8_1(active0, 0x2000000000L); case 112: - return jjMoveStringLiteralDfa8_0(active0, 0x200000000000L); + return jjMoveStringLiteralDfa8_1(active0, 0x1000000000000L); default: break; } - return jjStartNfa_0(6, active0); + return jjStartNfa_1(6, active0); } - private int jjMoveStringLiteralDfa8_0(long old0, long active0) { + private int jjMoveStringLiteralDfa8_1(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(6, old0); + return jjStartNfa_1(6, old0); try { curChar = input_stream.readChar(); } catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(7, active0); + jjStopStringLiteralDfa_1(7, active0); return 8; } switch (curChar) { case 100: - if ((active0 & 0x800000000000L) != 0L) - return jjStartNfaWithStates_0(8, 47, 11); + if ((active0 & 0x4000000000000L) != 0L) + return jjStartNfaWithStates_1(8, 50, 11); break; case 105: - return jjMoveStringLiteralDfa9_0(active0, 0x200000000000L); + return jjMoveStringLiteralDfa9_1(active0, 0x1000000000000L); case 110: - return jjMoveStringLiteralDfa9_0(active0, 0x400000000L); + return jjMoveStringLiteralDfa9_1(active0, 0x2000000000L); default: break; } - return jjStartNfa_0(7, active0); + return jjStartNfa_1(7, active0); } - private int jjMoveStringLiteralDfa9_0(long old0, long active0) { + private int jjMoveStringLiteralDfa9_1(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(7, old0); + return jjStartNfa_1(7, old0); try { curChar = input_stream.readChar(); } catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(8, active0); + jjStopStringLiteralDfa_1(8, active0); return 9; } switch (curChar) { case 103: - if ((active0 & 0x400000000L) != 0L) - return jjStopAtPos(9, 34); + if ((active0 & 0x2000000000L) != 0L) + return jjStopAtPos(9, 37); break; case 110: - return jjMoveStringLiteralDfa10_0(active0, 0x200000000000L); + return jjMoveStringLiteralDfa10_1(active0, 0x1000000000000L); default: break; } - return jjStartNfa_0(8, active0); + return jjStartNfa_1(8, active0); } - private int jjMoveStringLiteralDfa10_0(long old0, long active0) { + private int jjMoveStringLiteralDfa10_1(long old0, long active0) { if (((active0 &= old0)) == 0L) - return jjStartNfa_0(8, old0); + return jjStartNfa_1(8, old0); try { curChar = input_stream.readChar(); } catch (java.io.IOException e) { - jjStopStringLiteralDfa_0(9, active0); + jjStopStringLiteralDfa_1(9, active0); return 10; } switch (curChar) { case 103: - if ((active0 & 0x200000000000L) != 0L) - return jjStopAtPos(10, 45); + if ((active0 & 0x1000000000000L) != 0L) + return jjStopAtPos(10, 48); break; default: break; } - return jjStartNfa_0(9, active0); + return jjStartNfa_1(9, active0); } - private int jjStartNfaWithStates_0(int pos, int kind, int state) { + private int jjStartNfaWithStates_1(int pos, int kind, int state) { jjmatchedKind = kind; jjmatchedPos = pos; try { @@ -909,10 +914,10 @@ private int jjStartNfaWithStates_0(int pos, int kind, int state) { catch (java.io.IOException e) { return pos + 1; } - return jjMoveNfa_0(state, pos + 1); + return jjMoveNfa_1(state, pos + 1); } - private int jjMoveNfa_0(int startState, int curPos) { + private int jjMoveNfa_1(int startState, int curPos) { int startsAt = 0; jjnewStateCnt = 199; int i = 1; @@ -1067,8 +1072,8 @@ else if (curChar == 78) } break; case 2: - if (curChar == 115 && kind > 48) - kind = 48; + if (curChar == 115 && kind > 51) + kind = 51; break; case 3: case 20: @@ -1174,8 +1179,8 @@ else if (curChar == 78) } break; case 38: - if (curChar == 109 && kind > 37) - kind = 37; + if (curChar == 109 && kind > 40) + kind = 40; break; case 39: case 46: @@ -1237,8 +1242,8 @@ else if (curChar == 78) } break; case 54: - if (curChar == 121 && kind > 33) - kind = 33; + if (curChar == 121 && kind > 36) + kind = 36; break; case 55: if (curChar == 66) { @@ -1292,8 +1297,8 @@ else if (curChar == 78) } break; case 74: - if (curChar == 116 && kind > 30) - kind = 30; + if (curChar == 116 && kind > 33) + kind = 33; break; case 75: case 80: @@ -1335,8 +1340,8 @@ else if (curChar == 78) } break; case 86: - if (curChar == 103 && kind > 40) - kind = 40; + if (curChar == 103 && kind > 43) + kind = 43; break; case 87: case 99: @@ -1433,8 +1438,8 @@ else if (curChar == 78) jjstateSet[jjnewStateCnt++] = 109; break; case 111: - if (curChar == 121 && kind > 41) - kind = 41; + if (curChar == 121 && kind > 44) + kind = 44; break; case 112: if (curChar == 66) { @@ -1535,8 +1540,8 @@ else if (curChar == 78) jjstateSet[jjnewStateCnt++] = 134; break; case 136: - if (curChar == 103 && kind > 42) - kind = 42; + if (curChar == 103 && kind > 45) + kind = 45; break; case 137: case 148: @@ -1625,8 +1630,8 @@ else if (curChar == 78) jjstateSet[jjnewStateCnt++] = 157; break; case 159: - if (curChar == 110 && kind > 43) - kind = 43; + if (curChar == 110 && kind > 46) + kind = 46; break; case 160: case 167: @@ -1688,8 +1693,8 @@ else if (curChar == 78) } break; case 175: - if (curChar == 115 && kind > 38) - kind = 38; + if (curChar == 115 && kind > 41) + kind = 41; break; case 176: case 181: @@ -1730,8 +1735,8 @@ else if (curChar == 78) jjstateSet[jjnewStateCnt++] = 184; break; case 186: - if (curChar == 104 && kind > 39) - kind = 39; + if (curChar == 104 && kind > 42) + kind = 42; break; case 187: case 193: @@ -1823,11 +1828,196 @@ else if (curChar == 78) } } - private final int jjStopStringLiteralDfa_1(int pos, long active0) { + private final int jjStopStringLiteralDfa_0(int pos, long active0) { + switch (pos) { + default: + return -1; + } + } + + private final int jjStartNfa_0(int pos, long active0) { + return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); + } + + private int jjMoveStringLiteralDfa0_0() { + switch (curChar) { + case 40: + return jjStopAtPos(0, 30); + default: + return jjMoveNfa_0(0, 0); + } + } + + private int jjMoveNfa_0(int startState, int curPos) { + int startsAt = 0; + jjnewStateCnt = 22; + int i = 1; + jjstateSet[0] = startState; + int kind = 0x7fffffff; + for (; ; ) { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) { + long l = 1L << curChar; + do { + switch (jjstateSet[--i]) { + case 0: + if ((0x100002600L & l) != 0L) + kind = 7; + break; + default: + break; + } + } + while (i != startsAt); + } + else if (curChar < 128) { + long l = 1L << (curChar & 077); + do { + switch (jjstateSet[--i]) { + case 0: + if (curChar == 110) { + jjAddStates(26, 27); + } + else if (curChar == 116) { + jjAddStates(28, 29); + } + break; + case 1: + if (curChar == 116) { + jjAddStates(28, 29); + } + break; + case 2: + if (curChar == 113) + kind = 32; + break; + case 3: + if (curChar == 121) + kind = 32; + break; + case 4: + if (curChar == 114) + jjstateSet[jjnewStateCnt++] = 3; + break; + case 5: + if (curChar == 101) + jjstateSet[jjnewStateCnt++] = 4; + break; + case 6: + if (curChar == 117) + jjstateSet[jjnewStateCnt++] = 5; + break; + case 7: + if (curChar == 81) + jjstateSet[jjnewStateCnt++] = 6; + break; + case 8: + if (curChar == 109) + jjstateSet[jjnewStateCnt++] = 7; + break; + case 9: + if (curChar == 114) + jjstateSet[jjnewStateCnt++] = 8; + break; + case 10: + if (curChar == 101) + jjstateSet[jjnewStateCnt++] = 9; + break; + case 11: + if (curChar == 110) { + jjAddStates(26, 27); + } + break; + case 12: + if (curChar == 115) + kind = 31; + break; + case 13: + if (curChar == 116 && kind > 31) + kind = 31; + break; + case 14: + if (curChar == 101) + jjstateSet[jjnewStateCnt++] = 13; + break; + case 15: + if (curChar == 83) + jjstateSet[jjnewStateCnt++] = 14; + break; + case 16: + if (curChar == 99) + jjstateSet[jjnewStateCnt++] = 15; + break; + case 17: + if (curChar == 105) + jjstateSet[jjnewStateCnt++] = 16; + break; + case 18: + if (curChar == 114) + jjstateSet[jjnewStateCnt++] = 17; + break; + case 19: + if (curChar == 101) + jjstateSet[jjnewStateCnt++] = 18; + break; + case 20: + if (curChar == 109) + jjstateSet[jjnewStateCnt++] = 19; + break; + case 21: + if (curChar == 117) + jjstateSet[jjnewStateCnt++] = 20; + break; + default: + break; + } + } + while (i != startsAt); + } + else { + int hiByte = (curChar >> 8); + int i1 = hiByte >> 6; + long l1 = 1L << (hiByte & 077); + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + do { + switch (jjstateSet[--i]) { + case 0: + if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 7) + kind = 7; + break; + default: + if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) + break; + else + break; + } + } + while (i != startsAt); + } + if (kind != 0x7fffffff) { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 22 - (jjnewStateCnt = startsAt))) + return curPos; + try { + curChar = input_stream.readChar(); + } + catch (java.io.IOException e) { + return curPos; + } + } + } + + private final int jjStopStringLiteralDfa_2(int pos, long active0) { switch (pos) { case 0: - if ((active0 & 0x8000000000000L) != 0L) { - jjmatchedKind = 55; + if ((active0 & 0x40000000000000L) != 0L) { + jjmatchedKind = 58; return 6; } return -1; @@ -1836,43 +2026,43 @@ private final int jjStopStringLiteralDfa_1(int pos, long active0) { } } - private final int jjStartNfa_1(int pos, long active0) { - return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1); + private final int jjStartNfa_2(int pos, long active0) { + return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1); } - private int jjMoveStringLiteralDfa0_1() { + private int jjMoveStringLiteralDfa0_2() { switch (curChar) { case 84: - return jjMoveStringLiteralDfa1_1(0x8000000000000L); + return jjMoveStringLiteralDfa1_2(0x40000000000000L); case 93: - return jjStopAtPos(0, 52); + return jjStopAtPos(0, 55); case 125: - return jjStopAtPos(0, 53); + return jjStopAtPos(0, 56); default: - return jjMoveNfa_1(0, 0); + return jjMoveNfa_2(0, 0); } } - private int jjMoveStringLiteralDfa1_1(long active0) { + private int jjMoveStringLiteralDfa1_2(long active0) { try { curChar = input_stream.readChar(); } catch (java.io.IOException e) { - jjStopStringLiteralDfa_1(0, active0); + jjStopStringLiteralDfa_2(0, active0); return 1; } switch (curChar) { case 79: - if ((active0 & 0x8000000000000L) != 0L) - return jjStartNfaWithStates_1(1, 51, 6); + if ((active0 & 0x40000000000000L) != 0L) + return jjStartNfaWithStates_2(1, 54, 6); break; default: break; } - return jjStartNfa_1(0, active0); + return jjStartNfa_2(0, active0); } - private int jjStartNfaWithStates_1(int pos, int kind, int state) { + private int jjStartNfaWithStates_2(int pos, int kind, int state) { jjmatchedKind = kind; jjmatchedPos = pos; try { @@ -1881,10 +2071,10 @@ private int jjStartNfaWithStates_1(int pos, int kind, int state) { catch (java.io.IOException e) { return pos + 1; } - return jjMoveNfa_1(state, pos + 1); + return jjMoveNfa_2(state, pos + 1); } - private int jjMoveNfa_1(int startState, int curPos) { + private int jjMoveNfa_2(int startState, int curPos) { int startsAt = 0; jjnewStateCnt = 7; int i = 1; @@ -1899,8 +2089,8 @@ private int jjMoveNfa_1(int startState, int curPos) { switch (jjstateSet[--i]) { case 0: if ((0xfffffffeffffffffL & l) != 0L) { - if (kind > 55) - kind = 55; + if (kind > 58) + kind = 58; { jjCheckNAdd(6); } @@ -1920,23 +2110,23 @@ else if (curChar == 34) { break; case 2: if ((0xfffffffbffffffffL & l) != 0L) { - jjCheckNAddStates(26, 28); + jjCheckNAddStates(30, 32); } break; case 3: if (curChar == 34) { - jjCheckNAddStates(26, 28); + jjCheckNAddStates(30, 32); } break; case 5: - if (curChar == 34 && kind > 54) - kind = 54; + if (curChar == 34 && kind > 57) + kind = 57; break; case 6: if ((0xfffffffeffffffffL & l) == 0L) break; - if (kind > 55) - kind = 55; + if (kind > 58) + kind = 58; { jjCheckNAdd(6); } @@ -1955,14 +2145,14 @@ else if (curChar < 128) { case 6: if ((0xdfffffffdfffffffL & l) == 0L) break; - if (kind > 55) - kind = 55; + if (kind > 58) + kind = 58; { jjCheckNAdd(6); } break; case 2: { - jjAddStates(26, 28); + jjAddStates(30, 32); } break; case 4: @@ -1989,8 +2179,8 @@ else if (curChar < 128) { kind = 7; } if (jjCanMove_1(hiByte, i1, i2, l1, l2)) { - if (kind > 55) - kind = 55; + if (kind > 58) + kind = 58; { jjCheckNAdd(6); } @@ -1998,14 +2188,14 @@ else if (curChar < 128) { break; case 2: if (jjCanMove_1(hiByte, i1, i2, l1, l2)) { - jjAddStates(26, 28); + jjAddStates(30, 32); } break; case 6: if (!jjCanMove_1(hiByte, i1, i2, l1, l2)) break; - if (kind > 55) - kind = 55; + if (kind > 58) + kind = 58; { jjCheckNAdd(6); } @@ -2039,10 +2229,10 @@ else if (curChar < 128) { /** * Token literal values. */ - public static final String[] jjstrLiteralImages = { "", null, null, null, null, null, null, null, null, null, null, "\146\156\72", "\53", "\55", "\51", - "\72", "\75", "\74", "\74\75", "\76", "\76\75", "\136", "\176", null, null, null, null, "\133", "\173", "\50", null, "\141\146\164\145\162", - "\142\145\146\157\162\145", null, "\143\157\156\164\141\151\156\151\156\147", "\145\170\164\145\156\144", "\157\162", null, null, null, null, null, - null, null, "\157\162\144\145\162\145\144", "\157\166\145\162\154\141\160\160\151\156\147", "\160\150\162\141\163\145", + public static final String[] jjstrLiteralImages = { "", null, null, null, null, null, null, null, null, null, null, "\146\156\72", "\172\154\72", "\53", + "\55", "\51", "\72", "\75", "\74", "\74\75", "\76", "\76\75", "\136", "\176", null, null, null, null, "\133", "\173", "\50", null, null, null, + "\141\146\164\145\162", "\142\145\146\157\162\145", null, "\143\157\156\164\141\151\156\151\156\147", "\145\170\164\145\156\144", "\157\162", null, + null, null, null, null, null, null, "\157\162\144\145\162\145\144", "\157\166\145\162\154\141\160\160\151\156\147", "\160\150\162\141\163\145", "\165\156\157\162\144\145\162\145\144", null, "\167\151\154\144\143\141\162\144", "\167\151\164\150\151\156", "\124\117", "\135", "\175", null, null, "\100", }; @@ -2071,8 +2261,8 @@ protected Token jjFillToken() { return t; } - static final int[] jjnextStates = { 28, 30, 31, 15, 16, 18, 180, 185, 192, 198, 98, 110, 123, 135, 147, 158, 166, 173, 79, 84, 63, 72, 45, 52, 19, 36, 2, 4, - 5, }; + static final int[] jjnextStates = { 28, 30, 31, 15, 16, 18, 180, 185, 192, 198, 98, 110, 123, 135, 147, 158, 166, 173, 79, 84, 63, 72, 45, 52, 19, 36, 12, + 21, 2, 10, 2, 4, 5, }; private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) { switch (hiByte) { @@ -2107,8 +2297,8 @@ private static final boolean jjCanMove_2(int hiByte, int i1, int i2, long l1, lo } } - int curLexState = 2; - int defaultLexState = 2; + int curLexState = 3; + int defaultLexState = 3; int jjnewStateCnt; int jjround; int jjmatchedPos; @@ -2149,6 +2339,11 @@ public Token getNextToken() { jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_2(); break; + case 3: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_3(); + break; } if (jjmatchedKind != 0x7fffffff) { if (jjmatchedPos + 1 < curPos) @@ -2286,7 +2481,7 @@ public void ReInit(CharStream stream, int lexState) { * Switch to specified lex state. */ public void SwitchTo(int lexState) { - if (lexState >= 3 || lexState < 0) + if (lexState >= 4 || lexState < 0) throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); else curLexState = lexState; @@ -2295,14 +2490,14 @@ public void SwitchTo(int lexState) { /** * Lexer state names. */ - public static final String[] lexStateNames = { "Function", "Range", "DEFAULT", }; + public static final String[] lexStateNames = { "Zulia", "Function", "Range", "DEFAULT", }; /** * Lex State array. */ - public static final int[] jjnewLexState = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, - 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, -1, -1, -1, }; - static final long[] jjtoToken = { 0x1ffffffffffff01L, }; + public static final int[] jjnewLexState = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, + 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 3, -1, -1, -1, }; + static final long[] jjtoToken = { 0xfffffffffffff01L, }; static final long[] jjtoSkip = { 0x80L, }; static final long[] jjtoSpecial = { 0x0L, }; static final long[] jjtoMore = { 0x0L, }; diff --git a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/processors/ZuliaFieldableQueryNodeProcessor.java b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/processors/ZuliaFieldableQueryNodeProcessor.java new file mode 100644 index 00000000..51229108 --- /dev/null +++ b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/processors/ZuliaFieldableQueryNodeProcessor.java @@ -0,0 +1,43 @@ +package io.zulia.server.search.queryparser.processors; + +import io.zulia.server.config.IndexFieldInfo; +import io.zulia.server.config.ServerIndexConfig; +import io.zulia.server.search.queryparser.node.ZuliaFieldableQueryNode; +import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; +import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorImpl; + +import java.util.List; + +public class ZuliaFieldableQueryNodeProcessor extends QueryNodeProcessorImpl { + + /** + * Constructs a {@link ZuliaFieldableQueryNodeProcessor} object. + */ + public ZuliaFieldableQueryNodeProcessor() { + // empty constructor + } + + @Override + protected QueryNode postProcessNode(QueryNode node) { + + if (node instanceof ZuliaFieldableQueryNode zuliaFieldableQueryNode) { + String field = zuliaFieldableQueryNode.getField().toString(); + ServerIndexConfig indexConfig = getQueryConfigHandler().get(ZuliaQueryNodeProcessorPipeline.ZULIA_INDEX_CONFIG); + IndexFieldInfo indexFieldInfo = indexConfig.getIndexFieldInfo(field); + if (indexFieldInfo != null) { + zuliaFieldableQueryNode.setIndexFieldInfo(indexFieldInfo); + } + } + return node; + } + + @Override + protected QueryNode preProcessNode(QueryNode node) { + return node; + } + + @Override + protected List setChildrenOrder(List children) { + return children; + } +} diff --git a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/processors/ZuliaQueryNodeProcessorPipeline.java b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/processors/ZuliaQueryNodeProcessorPipeline.java index c798ed64..aa93ba39 100644 --- a/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/processors/ZuliaQueryNodeProcessorPipeline.java +++ b/zulia-query-parser/src/main/java/io/zulia/server/search/queryparser/processors/ZuliaQueryNodeProcessorPipeline.java @@ -50,6 +50,8 @@ public ZuliaQueryNodeProcessorPipeline(QueryConfigHandler queryConfig) { add(new OpenRangeQueryNodeProcessor()); //zulia - add ZuliaPointQueryNodeProcessor comment PointRangeQueryNodeProcessor add(new ZuliaPointQueryNodeProcessor()); + add(new ZuliaFieldableQueryNodeProcessor()); + //add(new PointRangeQueryNodeProcessor()); //zulia - remove term range query parser, replaced by ZuliaDateRangeQueryNodeProcessor above //add(new TermRangeQueryNodeProcessor()); diff --git a/zulia-server/src/main/java/io/zulia/server/index/ZuliaIndex.java b/zulia-server/src/main/java/io/zulia/server/index/ZuliaIndex.java index 1e9ad584..38843a9f 100644 --- a/zulia-server/src/main/java/io/zulia/server/index/ZuliaIndex.java +++ b/zulia-server/src/main/java/io/zulia/server/index/ZuliaIndex.java @@ -1,5 +1,6 @@ package io.zulia.server.index; +import com.google.protobuf.ProtocolStringList; import io.zulia.ZuliaFieldConstants; import io.zulia.message.ZuliaBase; import io.zulia.message.ZuliaBase.AssociatedDocument; @@ -35,6 +36,7 @@ import io.zulia.server.filestorage.DocumentStorage; import io.zulia.server.search.QueryCacheKey; import io.zulia.server.search.ShardQuery; +import io.zulia.server.search.queryparser.SetQueryHelper; import io.zulia.server.search.queryparser.ZuliaFlexibleQueryParser; import io.zulia.server.util.DeletingFileVisitor; import io.zulia.util.ZuliaThreadFactory; @@ -42,11 +44,6 @@ import org.apache.commons.pool2.PooledObject; import org.apache.commons.pool2.impl.DefaultPooledObject; import org.apache.commons.pool2.impl.GenericObjectPool; -import org.apache.lucene.document.DoublePoint; -import org.apache.lucene.document.FloatPoint; -import org.apache.lucene.document.IntPoint; -import org.apache.lucene.document.LongPoint; -import org.apache.lucene.document.SortedNumericDocValuesField; import org.apache.lucene.expressions.Expression; import org.apache.lucene.expressions.SimpleBindings; import org.apache.lucene.expressions.js.JavascriptCompiler; @@ -60,15 +57,11 @@ import org.apache.lucene.search.ConstantScoreQuery; import org.apache.lucene.search.DoubleValuesSource; import org.apache.lucene.search.FieldDoc; -import org.apache.lucene.search.IndexOrDocValuesQuery; import org.apache.lucene.search.KnnFloatVectorQuery; import org.apache.lucene.search.MatchAllDocsQuery; -import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.Query; -import org.apache.lucene.search.TermInSetQuery; import org.apache.lucene.search.TermQuery; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.NumericUtils; import org.bson.Document; import java.io.IOException; @@ -406,42 +399,30 @@ else if (query.getQfList().size() == 1) { } private Query getTermInSetQuery(ZuliaQuery.Query query, String field) { - - List termBytesRef = new ArrayList<>(); - for (String term : query.getTermList()) { - termBytesRef.add(new BytesRef(term)); - } - IndexFieldInfo indexFieldInfo = indexConfig.getIndexFieldInfo(field); if (indexFieldInfo == null) { throw new RuntimeException("Field <" + field + "> is not indexed"); } - String sortField = indexFieldInfo.getInternalSortFieldName(); + return SetQueryHelper.getTermInSetQuery(query.getTermList(), field, indexFieldInfo); + } - if (sortField != null) { - Query indexQuery = new TermInSetQuery(field, termBytesRef); - Query dvQuery = new TermInSetQuery(MultiTermQuery.DOC_VALUES_REWRITE, sortField, termBytesRef); - return new IndexOrDocValuesQuery(indexQuery, dvQuery); - } - return new TermInSetQuery(field, termBytesRef); - } public Query handleNumericSetQuery(ZuliaQuery.Query query) { - - if (query.getQfList().isEmpty()) { + ProtocolStringList qfList = query.getQfList(); + if (qfList.isEmpty()) { throw new IllegalArgumentException("Numeric set query must give at least one query field (qf)"); } - else if (query.getQfList().size() == 1) { - return getNumericSetQuery(query, query.getQfList().get(0)); + else if (qfList.size() == 1) { + return getNumericSetQuery(query.getNumericSet(), qfList.get(0)); } else { BooleanQuery.Builder booleanQueryBuilder = new BooleanQuery.Builder(); booleanQueryBuilder.setMinimumNumberShouldMatch(query.getMm()); - for (String field : query.getQfList()) { - Query inSetQuery = getNumericSetQuery(query, field); + for (String field : qfList) { + Query inSetQuery = getNumericSetQuery(query.getNumericSet(), field); booleanQueryBuilder.add(inSetQuery, BooleanClause.Occur.SHOULD); } return booleanQueryBuilder.build(); @@ -449,74 +430,10 @@ else if (query.getQfList().size() == 1) { } - private Query getNumericSetQuery(ZuliaQuery.Query query, String field) { + private Query getNumericSetQuery(ZuliaQuery.NumericSet numericSet, String field) { IndexFieldInfo indexFieldInfo = indexConfig.getIndexFieldInfo(field); - - FieldConfig.FieldType fieldType = indexFieldInfo.getFieldType(); - String searchField = indexFieldInfo.getInternalFieldName(); - String sortField = indexFieldInfo.getInternalSortFieldName(); - - ZuliaQuery.NumericSet numericSet = query.getNumericSet(); - - if (fieldType == null) { - throw new IllegalArgumentException("Field <" + field + "> is not indexed"); - } - else { - if (FieldTypeUtil.isNumericIntFieldType(fieldType)) { - List integerValueList = numericSet.getIntegerValueList(); - if (integerValueList.isEmpty()) { - throw new IllegalArgumentException("No integer values for integer field <" + field + "> for numeric set query"); - } - - Query pointQuery = IntPoint.newSetQuery(searchField, integerValueList); - if (sortField == null) { - return pointQuery; - } - long[] pointsArray = integerValueList.stream().mapToLong(Integer::intValue).toArray(); - return new IndexOrDocValuesQuery(pointQuery, SortedNumericDocValuesField.newSlowSetQuery(sortField, pointsArray)); - } - else if (FieldTypeUtil.isNumericLongFieldType(fieldType)) { - List longValueList = numericSet.getLongValueList(); - if (longValueList.isEmpty()) { - throw new IllegalArgumentException("No long values for long field <" + field + "> for numeric set query"); - } - - Query pointQuery = LongPoint.newSetQuery(searchField, longValueList); - if (sortField == null) { - return pointQuery; - } - long[] pointsArray = longValueList.stream().mapToLong(Long::longValue).toArray(); - return new IndexOrDocValuesQuery(pointQuery, SortedNumericDocValuesField.newSlowSetQuery(sortField, pointsArray)); - } - else if (FieldTypeUtil.isNumericFloatFieldType(fieldType)) { - List floatValueList = numericSet.getFloatValueList(); - if (floatValueList.isEmpty()) { - throw new IllegalArgumentException("No float values for float field <" + field + "> for numeric set query"); - } - - Query pointQuery = FloatPoint.newSetQuery(searchField, floatValueList); - if (sortField == null) { - return pointQuery; - } - long[] pointsArray = floatValueList.stream().mapToLong(NumericUtils::floatToSortableInt).toArray(); - return new IndexOrDocValuesQuery(pointQuery, SortedNumericDocValuesField.newSlowSetQuery(sortField, pointsArray)); - } - else if (FieldTypeUtil.isNumericDoubleFieldType(fieldType)) { - List doubleValueList = numericSet.getDoubleValueList(); - if (doubleValueList.isEmpty()) { - throw new IllegalArgumentException("No double values for double field <" + field + "> for numeric set query"); - } - - Query pointQuery = DoublePoint.newSetQuery(searchField, doubleValueList); - if (sortField == null) { - return pointQuery; - } - long[] pointsArray = doubleValueList.stream().mapToLong(NumericUtils::doubleToSortableLong).toArray(); - return new IndexOrDocValuesQuery(pointQuery, SortedNumericDocValuesField.newSlowSetQuery(sortField, pointsArray)); - } - } - throw new IllegalArgumentException("No field type of <" + fieldType + "> is not supported for numeric set queries"); - + return SetQueryHelper.getNumericSetQuery(field, indexFieldInfo, numericSet::getIntegerValueList, numericSet::getLongValueList, + numericSet::getFloatValueList, numericSet::getDoubleValueList); } public Query handleVectorQuery(ZuliaQuery.Query query) throws Exception { diff --git a/zulia-server/src/test/java/io/zulia/server/test/node/NumericSetTest.java b/zulia-server/src/test/java/io/zulia/server/test/node/NumericSetTest.java index 96552e09..ddb0bb10 100644 --- a/zulia-server/src/test/java/io/zulia/server/test/node/NumericSetTest.java +++ b/zulia-server/src/test/java/io/zulia/server/test/node/NumericSetTest.java @@ -2,6 +2,7 @@ import io.zulia.DefaultAnalyzers; import io.zulia.client.command.Store; +import io.zulia.client.command.builder.FilterQuery; import io.zulia.client.command.builder.NumericSetQuery; import io.zulia.client.command.builder.Search; import io.zulia.client.command.builder.Sort; @@ -44,6 +45,8 @@ public void createIndex() throws Exception { indexConfig.addFieldConfig(FieldConfigBuilder.createLong("longField").index()); indexConfig.addFieldConfig(FieldConfigBuilder.createFloat("floatField").index()); indexConfig.addFieldConfig(FieldConfigBuilder.createDouble("doubleField").index()); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("fn").indexAs(DefaultAnalyzers.STANDARD)); + indexConfig.addFieldConfig(FieldConfigBuilder.createString("zl").indexAs(DefaultAnalyzers.STANDARD)); indexConfig.setIndexName(NUMERIC_SET_TEST); indexConfig.setNumberOfShards(1); indexConfig.setShardCommitInterval(20); //force some commits @@ -75,6 +78,14 @@ private void indexRecord(int id, int i, long l, float f, double d) throws Except mongoDocument.put("floatField", f); mongoDocument.put("doubleField", d); + if (id == 1) { + mongoDocument.put("fn", "ordered"); + } + + if (id == 2) { + mongoDocument.put("zl", "ns"); + } + Store s = new Store(uniqueId, NUMERIC_SET_TEST); ResultDocBuilder resultDocumentBuilder = ResultDocBuilder.newBuilder().setDocument(mongoDocument); @@ -111,6 +122,60 @@ public void searchTest() throws Exception { Assertions.assertEquals("2", searchResult.getCompleteResults().get(1).getUniqueId()); Assertions.assertEquals("5", searchResult.getCompleteResults().get(2).getUniqueId()); + search = new Search(NUMERIC_SET_TEST); + search.addQuery(new FilterQuery("intField:zl:ns(1 2)")).addSort(new Sort("id")); + search.setAmount(10); + searchResult = zuliaWorkPool.search(search); + Assertions.assertEquals(3, searchResult.getTotalHits()); + + Assertions.assertEquals("1", searchResult.getCompleteResults().get(0).getUniqueId()); + Assertions.assertEquals("2", searchResult.getCompleteResults().get(1).getUniqueId()); + Assertions.assertEquals("5", searchResult.getCompleteResults().get(2).getUniqueId()); + + search = new Search(NUMERIC_SET_TEST); + search.addQuery(new FilterQuery("zl:ns(1 2)").addQueryField("intField")).addSort(new Sort("id")); + search.setAmount(10); + searchResult = zuliaWorkPool.search(search); + Assertions.assertEquals(3, searchResult.getTotalHits()); + + Assertions.assertEquals("1", searchResult.getCompleteResults().get(0).getUniqueId()); + Assertions.assertEquals("2", searchResult.getCompleteResults().get(1).getUniqueId()); + Assertions.assertEquals("5", searchResult.getCompleteResults().get(2).getUniqueId()); + + //IllegalArgumentException:Search: For input string: "abcd" + Assertions.assertThrows(Exception.class, () -> { + Search s = new Search(NUMERIC_SET_TEST); + s.addQuery(new FilterQuery("zl:ns(1 abcd)").addQueryField("intField")).addSort(new Sort("id")); + s.setAmount(10); + zuliaWorkPool.search(s); + }); + + //Exception:Search: Field must be indexed for numeric set queries + Assertions.assertThrows(Exception.class, () -> { + Search s = new Search(NUMERIC_SET_TEST); + s.addQuery(new FilterQuery("zl:ns(1 2)").addQueryField("title")).addSort(new Sort("id")); + s.setAmount(10); + zuliaWorkPool.search(s); + }); + + search = new Search(NUMERIC_SET_TEST); + search.addQuery(new FilterQuery("intField,longField:zl:ns(1 2 5)")).addSort(new Sort("id")); + search.setAmount(10); + searchResult = zuliaWorkPool.search(search); + Assertions.assertEquals(5, searchResult.getTotalHits()); + + search = new Search(NUMERIC_SET_TEST); + search.addQuery(new FilterQuery("intField,longField:zl:ns(1 2 5) -id:1")).addSort(new Sort("id")); + search.setAmount(10); + searchResult = zuliaWorkPool.search(search); + Assertions.assertEquals(4, searchResult.getTotalHits()); + + search = new Search(NUMERIC_SET_TEST); + search.addQuery(new FilterQuery("zl:ns(1 2 5)").addQueryFields("intField", "longField")).addSort(new Sort("id")); + search.setAmount(10); + searchResult = zuliaWorkPool.search(search); + Assertions.assertEquals(5, searchResult.getTotalHits()); + search = new Search(NUMERIC_SET_TEST); search.addQuery(new NumericSetQuery("longField").addValues(1L)); search.setAmount(10); @@ -123,12 +188,46 @@ public void searchTest() throws Exception { searchResult = zuliaWorkPool.search(search); Assertions.assertEquals(2, searchResult.getTotalHits()); + search = new Search(NUMERIC_SET_TEST); + search.addQuery(new FilterQuery("zl:ns(565.0 2000)").addQueryField("floatField")).addSort(new Sort("id")); + search.setAmount(10); + searchResult = zuliaWorkPool.search(search); + Assertions.assertEquals(2, searchResult.getTotalHits()); + search = new Search(NUMERIC_SET_TEST); search.addQuery(new NumericSetQuery("doubleField").addValues(2.01, 2.0)); search.setAmount(3); searchResult = zuliaWorkPool.search(search); Assertions.assertEquals(3, searchResult.getTotalHits()); + search = new Search(NUMERIC_SET_TEST); + search.addQuery(new FilterQuery("doubleField:zl:ns(2.01 2.0)")).addSort(new Sort("id")); + search.setAmount(10); + searchResult = zuliaWorkPool.search(search); + Assertions.assertEquals(3, searchResult.getTotalHits()); + + // to query fn or zl, need to use multi-field syntax trick to query or use query fields + + search = new Search(NUMERIC_SET_TEST); + search.addQuery(new FilterQuery("ordered").addQueryFields("fn")); + searchResult = zuliaWorkPool.search(search); + Assertions.assertEquals(1, searchResult.getTotalHits()); + + search = new Search(NUMERIC_SET_TEST); + search.addQuery(new FilterQuery("fn,:ordered")); + searchResult = zuliaWorkPool.search(search); + Assertions.assertEquals(1, searchResult.getTotalHits()); + + search = new Search(NUMERIC_SET_TEST); + search.addQuery(new FilterQuery("ns").addQueryFields("zl")); + searchResult = zuliaWorkPool.search(search); + Assertions.assertEquals(1, searchResult.getTotalHits()); + + search = new Search(NUMERIC_SET_TEST); + search.addQuery(new FilterQuery("zl,:ns")); + searchResult = zuliaWorkPool.search(search); + Assertions.assertEquals(1, searchResult.getTotalHits()); + } @Test diff --git a/zulia-server/src/test/java/io/zulia/server/test/node/StartStopTest.java b/zulia-server/src/test/java/io/zulia/server/test/node/StartStopTest.java index e409bc4c..3ccad227 100644 --- a/zulia-server/src/test/java/io/zulia/server/test/node/StartStopTest.java +++ b/zulia-server/src/test/java/io/zulia/server/test/node/StartStopTest.java @@ -348,24 +348,59 @@ public void termTestBuilder() throws Exception { searchResult = zuliaWorkPool.search(s); Assertions.assertEquals(4, searchResult.getTotalHits()); + s = new Search(FACET_TEST_INDEX); + s.addQuery(new FilterQuery("testBool:true AND id:zl:tq(1 2 3 4)")); + searchResult = zuliaWorkPool.search(s); + Assertions.assertEquals(4, searchResult.getTotalHits()); + s = new Search(FACET_TEST_INDEX); s.addQuery(new TermQuery("id").addTerm("1").addTerm("2").addTerm("3").addTerm("4")); s.addQuery(new FilterQuery("country:US")); searchResult = zuliaWorkPool.search(s); Assertions.assertEquals(2, searchResult.getTotalHits()); + s = new Search(FACET_TEST_INDEX); + s.addQuery(new FilterQuery("id:zl:tq(1 2 3 4) AND country:US")); + searchResult = zuliaWorkPool.search(s); + Assertions.assertEquals(2, searchResult.getTotalHits()); + s = new Search(FACET_TEST_INDEX); s.addQuery(new TermQuery("id").addTerm("1").addTerm("2").addTerm("3").addTerm("4").exclude()); s.addQuery(new FilterQuery("country:US")); searchResult = zuliaWorkPool.search(s); Assertions.assertEquals(28, searchResult.getTotalHits()); + s = new Search(FACET_TEST_INDEX); + s.addQuery(new FilterQuery("-id:zl:tq(1 2 3 4) AND country:US")); + searchResult = zuliaWorkPool.search(s); + Assertions.assertEquals(28, searchResult.getTotalHits()); + s = new Search(FACET_TEST_INDEX); s.addQuery(new TermQuery("id").addTerm("1").addTerm("2").addTerm("3").addTerm("4").exclude()); s.addQuery(new FilterQuery("country:US").exclude()); s.addQuery(new MatchAllQuery()); //need to use match all because all other queries are negated searchResult = zuliaWorkPool.search(s); Assertions.assertEquals(28, searchResult.getTotalHits()); + + s = new Search(FACET_TEST_INDEX); + s.addQuery(new FilterQuery("-id:zl:tq(1 2 3 4) AND -country:US")); + searchResult = zuliaWorkPool.search(s); + Assertions.assertEquals(28, searchResult.getTotalHits()); + + s = new Search(FACET_TEST_INDEX); + s.addQuery(new FilterQuery("title:zl:tq(facet)")); + searchResult = zuliaWorkPool.search(s); + Assertions.assertEquals(25, searchResult.getTotalHits()); + + s = new Search(FACET_TEST_INDEX); + s.addQuery(new FilterQuery("title:zl:tq(facet userguide)")); + searchResult = zuliaWorkPool.search(s); + Assertions.assertEquals(50, searchResult.getTotalHits()); + + s = new Search(FACET_TEST_INDEX); + s.addQuery(new FilterQuery("issn:zl:tq(\"1234-1234\" \"3333-1234\" \"1234-5555\")")); + searchResult = zuliaWorkPool.search(s); + Assertions.assertEquals(30, searchResult.getTotalHits()); } @Test