Prefix query in SimpleQueryString predicate is case sensitive

Description

Ineffective search for the "simpleQueryString_" predicate. The SimpleQueryParser class requires the "flags" parameter in the constructor. Currently, the "flags" parameter is set to "-1", which means that the operation of this predicate does not differ from the "match" predicate. Unfortunately, this makes the predicate completely useless. The correct operation of SimpleQueryParser depends on the settings of these flags, however it is not possible to set them by defining predicates.

/** Enables {@code AND} operator */
public static final int AND_OPERATOR = 1<<0;
/** Enables {@code NOT} operator */
public static final int NOT_OPERATOR = 1<<1;
/** Enables {@code OR} operator (|) */
public static final int OR_OPERATOR = 1<<2;
/** Enables {@code PREFIX} operator */
public static final int PREFIX_OPERATOR = 1<<3;
/** Enables {@code PHRASE} operator (") */
public static final int PHRASE_OPERATOR = 1<<4;
/** Enables {@code PRECEDENCE} operators: {@code (} and {@code )} */
public static final int PRECEDENCE_OPERATORS = 1<<5;
/** Enables {@code ESCAPE} operator () */
public static final int ESCAPE_OPERATOR = 1<<6;
/** Enables {@code WHITESPACE} operators: ' ' '\n' '\r' '\t' */
public static final int WHITESPACE_OPERATOR = 1<<7;
/** Enables {@code FUZZY} operators: (~) on single terms */
public static final int FUZZY_OPERATOR = 1<<8;
/** Enables {@code NEAR} operators: (~) on phrases */
public static final int NEAR_OPERATOR = 1<<9;

Environment

None

Activity

Show:
Waldemar Kłaczyński
February 27, 2020, 11:40 PM
Edited

Maybe you should add the "flags()" predicate?

Waldemar Kłaczyński
February 28, 2020, 12:35 AM
Edited

Alternate query works fine. The problem is that it doesn't complete all the queries as per the documentation.


Does not return results for:

 

But it works well for:

It doesn't seem to make sense to use FieldContextSimpleQueryParser and only introduces errors.

Waldemar Kłaczyński
February 28, 2020, 1:18 AM
Edited

I solved the problem in LuceneSimpleQueryStringPredicateBuilder, after making these changes the problem disappeared.


 

Waldemar Kłaczyński
February 28, 2020, 4:42 AM

I have also added support for operation flags. It is now possible to set in the predicate what operations are possible in the query. By default, if you do not call "flags()", all operations are set.

 

Yoann Rodière
February 28, 2020, 8:18 AM

I'm a bit confused, to be honest.

There is no way to customize the enabled flags right now. That can be annoying, and adding methods to control that is definitely a good idea. However, *all flags are enabled* by default. As you noticed yourself, passing "-1" as a flag simply enables all features (that's what you did in your snippet of code).

So I'm not sure how your patch solved the problem exactly, and I'm not even sure what caused the problem. Maybe it was indeed FieldContextSimpleQueryParser? It looks like it doesn't normalize terms before creating queries, like it should. Depending on your analyzer, that could cause no results to be returned.

That being said, if you manage to make it work using standard Lucene classes instead of our custom query parser *and* to make all pre-existing integration tests pass... Well, that would be awesome.

Assignee

Waldemar Kłaczyński

Reporter

Waldemar Kłaczyński

Labels

None

Suitable for new contributors

None

Feedback Requested

None

Components

Fix versions

Affects versions

Priority

Major
Configure