Opened 18 years ago
Last modified 21 months ago
#159 new enhancement
Should be possible to introspect on Query objects
Reported by: | Richard Boulton | Owned by: | Not currently assigned |
---|---|---|---|
Priority: | normal | Milestone: | 2.0.0 |
Component: | Library API | Version: | git master |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Operating System: | All |
Description (last modified by )
In particular, it should be possible to determine the operator performed by the "top-level" query in the query object, get a list of the subqueries, get any appropriate parameters supplied (eg, valno and end of range for a VALUE_RANGE query, window size for a phrase query, etc) and get the term, wqf and position for a leaf query.
This API will necessarily involve quite a few methods - we need to make sure that it is no more complicated than really necessary, and be sure that it doesn't expose internals of the query representation (preventing us modifying these in future).
One particular issue is that we can't easily just return the "operator" used in the query, because leaf queries use a special "magic" value for the operator parameter. There are several solutions to this: 1) make OP_LEAF public. 2) make "get_operator()" return -1, and just document that it does that, 3) add an "is_leaf()" method, and document that get_operator() shouldn't be called unless "is_leaf()" returns false.
Attachments (1)
Change History (8)
comment:1 by , 18 years ago
Operating System: | → All |
---|---|
Owner: | changed from | to
by , 18 years ago
Attachment: | query_introspect.patch added |
---|
Sketch of some of the API required for this
comment:3 by , 17 years ago
Description: | modified (diff) |
---|---|
Type: | defect → enhancement |
comment:4 by , 11 years ago
Milestone: | → 1.3.x |
---|
f4f38b0cde256a6881a2086cbe83ee11260ce33a adds the start of an introspection interface - with what's there you can walk the query tree and get the type of each node.
Query::get_terms_begin()
allows you to read the term for a node which is a term - not sure if an additional method to get the termname directly is worthwhile or not.
I've not yet added methods to allow introspection of all the details of all query types, and I've not yet added any test coverage (though it does at least work in informal testing).
comment:5 by , 11 years ago
Milestone: | 1.3.x → 1.3.3 |
---|
comment:6 by , 10 years ago
Milestone: | 1.3.3 → 1.3.4 |
---|
comment:8 by , 21 months ago
Milestone: | 1.4.x → 2.0.0 |
---|---|
Version: | SVN trunk → git master |
[4fb286495452f96c077fc31d85aaed95f1ab9ce5] allows introspecting on wqf and pos for terms in a query.
More could be done, though - as the original report says "eg, valno and end of range for a VALUE_RANGE query, window size for a phrase query, etc".
This isn't a release blocker though.
(reassigning to nobody, since I don't think Olly's likely to be working hard on this right now, and nor am I.)
I forgot to mention two reasons for wanting this support: