[
https://issues.apache.org/jira/browse/LUCENE-10432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17498238#comment-17498238
]
Andriy Redko edited comment on LUCENE-10432 at 2/25/22, 9:25 PM:
-----------------------------------------------------------------
[~jpountz] as progressed along the use cases, I have exact answer to your
question / concern: \{{Weight#explain }} does not need to be changed, nor the
Query, the Explanation could be copied & enriched in place, if needed, an
example in pseudo code is below:
{noformat}
Explanation expl = subQueryWeight.explain(context, doc)
return // copy of expl with (description += query name); {noformat}
PS: I am using the `description` here as of today, but imagine the following
alternatives:
{noformat}
return expl.copyWithName(query name); {noformat}
{noformat}
return expl.copyWithTags("name", "query name"); {noformat}
But surely, not bullet proof option (fe BooleanWeight#explain) but at least
having the way to propagate such context is already helpful.
WDYT?
was (Author: reta):
[~jpountz] as progressed along the use cases, I have exact answer to your
question / concern: \{{Weight#explain }}does not need to be changed, northe
Query, the Explanation could be copied & enriched in place, if needed, an
example in pseudo code is below:
{noformat}
Explanation expl = subQueryWeight.explain(context, doc)
return // copy of expl with (description += query name); {noformat}
PS: I am using the `description` here as of today, but imagine the following
alternatives:
{noformat}
return expl.copyWithName(query name); {noformat}
{noformat}
return expl.copyWithTags("name", "query name"); {noformat}
WDYT?
> Add optional 'name' property to org.apache.lucene.search.Explanation
> ---------------------------------------------------------------------
>
> Key: LUCENE-10432
> URL: https://issues.apache.org/jira/browse/LUCENE-10432
> Project: Lucene - Core
> Issue Type: Improvement
> Affects Versions: 9.0, 8.10.1
> Reporter: Andriy Redko
> Priority: Minor
>
> Right now, the `Explanation` class has the `description` property which is
> used pretty much as placeholder for free-style, human readable summary of
> what is happening. This is totally fine but it would be great to have a bit
> more formal way to link the explanation with corresponding function / query /
> filter if supported by the underlying engine.
> Example: Opensearch / Elasticseach has the concept of named queries / filters
> [1]. This is not supported by Apache Lucene at the moment but it would be
> helpful to propagate this information back as part of Explanation tree, for
> example by introducing optional 'name' property:
>
> {noformat}
> {
> "value": 0.0,
> "description": "script score function, computed with script: ...",
>
> "name": "script1",
> "details": [
> {
> "value": 1.0,
> "description": "_score: ",
> "details": [
> {
> "value": 1.0,
> "description": "*:*",
> "details": []
> }
> ]
> }
> ]
> }{noformat}
>
> From the other side, the `name` property may look like not belonging here,
> the alternative suggestion would be to add support of `properties` /
> `parameters` / `tags` key/value bag, for example:
>
> {noformat}
> {
> "value": 0.0,
> "description": "script score function, computed with script: ...",
>
> "tags": [
> { "name": "script1" }
> ],
> "details": [
> {
> "value": 1.0,
> "description": "_score: ",
> "details": [
> {
> "value": 1.0,
> "description": "*:*",
> "details": []
> }
> ]
> }
> ]
> }{noformat}
> The change should be non-breaking but quite useful for engines to enrich the
> `Explanation` with additional context.
> [1]
> https://www.elastic.co/guide/en/elasticsearch/reference/7.16/query-dsl-bool-query.html#named-queries
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]