Opened 9 years ago
Last modified 5 months ago
#720 new defect
range vs filter prefixes
Reported by: | Olly Betts | Owned by: | Olly Betts |
---|---|---|---|
Priority: | highest | Milestone: | 2.0.0 |
Component: | QueryParser | Version: | 1.3.5 |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Operating System: | All |
Description
For a range, a prefix like date:
needs to be specified with the :
(which is because a prefix like $
is allowed).
But for a filter, the :
is implicit, and you shouldn't explicitly include it.
This is an inconsistency in the API, and those make the API harder to learn and use.
I think the simplest solution is to optionally allow the :
for a filter. Perhaps we should also encourage explicitly specifying it, with an eye to later supporting filters with a prefix which isn't "word and a colon", e.g. #1234
instead of sku:1234
, @olly
instead of user:olly
.
Change History (6)
comment:1 by , 5 years ago
comment:2 by , 3 years ago
While date2019-08-09
doesn't seem useful, maybe SKU31415
is - for example in an online shop a search for a part code could then be made to reliably return just that item.
It would need to be used with a bit of care to not be confusing though.
comment:3 by , 21 months ago
Milestone: | 1.4.x → 2.0.0 |
---|
comment:4 by , 21 months ago
Milestone: | 2.0.0 → 1.5.0 |
---|
Oops, I meant 1.5.0. As noted above this could be backported to 1.4.x if it's not too invasive. We're quite late in the 1.4.x development cycle, but cases like this where we're aiming to improve forward compatibility are worth considering. This needs doing for master first regardless.
comment:5 by , 13 months ago
Priority: | normal → highest |
---|
comment:6 by , 5 months ago
Milestone: | 1.5.0 → 2.0.0 |
---|
maybe SKU31415 is [useful]
I think that's probably not a useful direction to try to go. It gets complex to implement and it's harder for users to understand.
field:
prefixes are easy for both implementing and users, and things like @olly
and #1234
reasonably so too.
For now I've just added a tweak to allow an optional :
on the field parameter from 1.4.26 (043b292aae29ee676f5fa964d3c6a900c4d71307 for master; d38234c44d9abe8aa781738c0a9dfe9fae9db39c for RELEASE/1.4).
Actually implementing filter prefix support for @olly
, #1234
is for later.
To allow a smooth transition, I suggest we change the code to add
:
for a filter but only if the prefix ends in an alphanumeric (or maybe a word character, or some rule along these lines). That waydate
->date:
,date:
continues to work, and cases such as@
,#
, etc can be supported. It doesn't seem useful to try to support parsing something such as:date2019-08-09
This isn't the incompatible change it seems since the way the
QueryParser
currently parses filter prefixes means that specifying a mapping fromdate:
,@
or#
is currently effectively ignored (because the prefix is parsed as a series of word characters followed by a:
). So that would be suitable for 1.4.x too, provided the code changes for handling prefixes such as@
and#
aren't too invasive. If they are, we could easily just allowdate:
to mean the same asdate
at least, and leave cases such as@
and#
for git master, or even for the future.