Bug 1410112 - Allow boolean expressions in Lucene filters
Summary: Allow boolean expressions in Lucene filters
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Beaker
Classification: Retired
Component: inventory
Version: 23
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
Assignee: beaker-dev-list
QA Contact: tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-01-04 13:52 UTC by Jiri Jaburek
Modified: 2020-10-21 14:13 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2020-10-21 14:13:52 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1401964 0 medium CLOSED [RFE] Expose the "id" field of activity log to Lucene query filters used by HTTP API 2021-02-22 00:41:40 UTC

Internal Links: 1401964

Description Jiri Jaburek 2017-01-04 13:52:00 UTC
Description of problem:

When I query a system's activity log, I can only use one field in the Lucene expression - whenever I use AND/OR (or a query with space, %20, anywhere), I get an empty result.

$ curl -sf 'https://<hub>/systems/<fqdn>/activity/?q=action:on%20AND%20field_name:Power'
{
  "count": 0, 
  "entries": [], 
  "page": 1, 
  "page_size": 20, 
  "q": "action:on AND field_name:Power"
}

Both of these fields work when used individually.


Version-Release number of selected component (if applicable):
23.3

How reproducible:
always

Steps to Reproduce:
1. curl -sf 'https://<hub>/systems/<fqdn>/activity/?q=action:on%20AND%20field_name:Power'

Actual results:
Beaker returns empty result set

Expected results:
Beaker returns entries matching the expression

Additional info:
http://lucene.apache.org/core/2_9_4/queryparsersyntax.html#Boolean%20operators

Comment 1 Dan Callaghan 2017-01-04 23:42:01 UTC
The Beaker JSON endpoints don't understand AND or OR operators currently. But actually the default is already AND when you specify multiple terms (there is no way specify OR currently). So the search you want to do here is just:

action:on field_name:Power

It seems that this default is contradictory to the Lucene query parser defaults, and is also not mentioned in our Beaker docs. (I think it matches the Solr default behaviour though.) So we should document that better at least.

Comment 2 Jiri Jaburek 2017-01-05 11:20:08 UTC
Oh, I tried that (as the Lucene page mentions it as the alternative syntax to AND), but it somehow didn't work. Trying it again, it seems to work indeed. Thanks.

Comment 3 Dan Callaghan 2017-01-06 00:55:48 UTC
(In reply to Jiri Jaburek from comment #2)

If you put the actual word "AND" into your search it would probably return no results because it is trying to search for the string "AND" (contrary to how the real Lucene query parser works) which most likely doesn't appear in any rows. So maybe that is why.

Comment 4 Jiri Jaburek 2017-01-06 12:19:28 UTC
(In reply to Dan Callaghan from comment #3)
> (In reply to Jiri Jaburek from comment #2)
> 
> If you put the actual word "AND" into your search it would probably return
> no results because it is trying to search for the string "AND" (contrary to
> how the real Lucene query parser works) which most likely doesn't appear in
> any rows. So maybe that is why.

No, I simply used space-separated keywords which is the "alternative syntax" I mentioned - from the apache.org page:

    The OR operator is the default conjunction operator. This means that if
    there is no Boolean operator between two terms, the OR operator is used.
    To search for documents that contain either "jakarta apache" or just
    "jakarta" use the query:
        "jakarta apache" jakarta
    or
        "jakarta apache" OR jakarta

However I misremembered it as AND instead of OR, which would explain my confusion. Beaker indeed treats space-separation as AND, as you explained above.

Comment 5 Roman Joost 2017-01-10 00:37:01 UTC
As a short term fix I've filed Bug 1411560 to document what is currently different. Long term, this bug is about fixing the differences and provide the full Lucene query parser syntax.


Note You need to log in before you can comment on or make changes to this bug.