Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It shouldn't possible to save empty filter rules #51

Closed
ChristianSchaefer opened this issue Nov 6, 2020 · 4 comments
Closed

It shouldn't possible to save empty filter rules #51

ChristianSchaefer opened this issue Nov 6, 2020 · 4 comments

Comments

@ChristianSchaefer
Copy link

ChristianSchaefer commented Nov 6, 2020

Hi,

we had the problem, that it is possible to save empty filter rules, which leads to a syntax error, when deploying into solr.
Here is an excerpt of our rules-smt file

DOWN(50): * manufacturer:Wiko
DOWN(50): * manufacturer:ZTE
DOWN(10): * searchText:"Iphone 11"
FILTER: * -searchText:
FILTER: * -searchText:"Mi Smart Plug"
FILTER: * -searchText:"Roboter-Staubsauger"

@pbartusch
Copy link
Collaborator

hi @ChristianSchaefer ,

I understand, you are referring to the rule:

FILTER: * -searchText:

presumably you'd like to express a rule, that states:

"For the managed query, the (Solr) field searchText should not be searches at all"

Is that correct?

The following rule definition will be positively validated by Querqy:

FILTER: * -searchText: *

Although I am not sure, what will be the specified outcome of that in Querqy ( @renekrie ?), and if there is even a way to use Querqy's CommonRuleRewriter in a way, that it prevents complete fields from being searched by Solr/Lucene.

Very interesting case though!! @ChristianSchaefer , it would be great to learn more about your use case intent , and wether above's suggestion works for you!?

@renekrie
Copy link
Collaborator

renekrie commented Nov 7, 2020

FILTER: * -searchText: is indeed invalid Solr/Lucene syntax.

@pbartusch I think your solution FILTER: * -searchText:* could work (I'd remove the space after the colon though).

I think @ChristianSchaefer's point is that it shouldn't be possible to save such a rule in SMUI. Overall, whatever you put in that query string is completely transparent to Querqy - it will just ask Solr to parse the query at runtime. Unfortunately, we cannot validate Lucene/Syntax 100% outside Solr. For example, the query string might use plugged in custom query parsers that we don't know about in SMUI. Also, we cannot validate that a field exists. Strictly spoken, in some cases we might not even know that a given piece of the string refers to a field.

However, we should make sure that this is not a rule that was produced by SMUI, for example, when the user entered a field name in the UI without specifying any field value.

@ChristianSchaefer
Copy link
Author

@renekrie is right. It shouldn't be possible to save empty rules or a warning should appear, if this is a desired feature. If you save an empty rule with *, the result of the query isn't predictable, right?

@pbartusch
Copy link
Collaborator

thanks @ChristianSchaefer for the report. I released v3.11.11 , that should solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants