[
https://issues.apache.org/jira/browse/SOLR-18664?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18150075#comment-18150075
]
ASF subversion and git services commented on SOLR-18664:
--------------------------------------------------------
Commit 0306b358cfd117a827c73f6cf999b961c74a740b in solr's branch
refs/heads/main from Rahul Goswami
[ https://gitbox.apache.org/repos/asf?p=solr.git;h=0306b358cfd ]
SOLR-18664: Add expandFilter to the graph query parser (#5356)
Add an expandFilter local param to the {!graph} query parser. Documents
reached by the traversal are still collected and returned, but only those
matching expandFilter have their edges followed to the next hop. Unlike
traversalFilter, it doesn't change which documents are returned, only which
ones are expanded. It also applies to the root documents.
This avoids building next-hop queries from nodes known to have no
children, e.g. files in a file/folder hierarchy
(expandFilter=docType:folder), which can make deep traversals much faster.
Reviewed-by: Mikhail Khludnev and David Smiley
Co-authored-by: Claude Opus 5.5 <[email protected]>
> Skip edge lookups in graph query parser for nodes that can't have children
> --------------------------------------------------------------------------
>
> Key: SOLR-18664
> URL: https://issues.apache.org/jira/browse/SOLR-18664
> Project: Solr
> Issue Type: Improvement
> Components: query parsers
> Affects Versions: 10.1, 9.11
> Reporter: Rahul Goswami
> Assignee: Rahul Goswami
> Priority: Major
> Labels: pull-request-available
> Fix For: 9.12, 10.2
>
> Time Spent: 2h
> Remaining Estimate: 0h
>
> h3. Problem
> The graph query parser does a breadth-first traversal: at each hop it reads
> the {{to}} field of every collected document and adds those values to the
> next hop's {{from IN (...)}} frontier query. There is no way to say "collect
> this node, but don't expand it".
> A common case is a file-system hierarchy, where every document (file or
> folder) has its own id in {{id}} and its parent's id in {{{}parentId{}}}:
> {noformat}
> q={!graph from=parentId to=id returnRoot=true
> traversalFilter=name:prefix*}<root folder query>
> {noformat}
> Only folders ({{{}docType:folder{}}}) can have children, but every file's
> ({{{}docType:file{}}}) {{id}} also becomes a term in the next hop's query.
> Each such term costs a docValues read, a hash insert and a terms-dictionary
> seek per segment, and can never match. Files usually far outnumber folders,
> so most of the frontier is wasted work.
> * {{traversalFilter=docType:folder}} doesn't help: it restricts which
> documents are collected, so files would be dropped from the results.
> * The existing leaf-node optimization ({{{}resolveLeafNodes(){}}}) only
> skips documents with *no value* in the {{to}} field. Here every document has
> an {{{}id{}}}, so it never applies.
> h3. Proposal
> Add an optional {{expandFilter}} local param. Documents reached by the
> traversal (and matching {{{}traversalFilter{}}}) are always collected, but
> only those that also match {{expandFilter}} have their edges followed. It
> applies at every level, including the root. When absent, behaviour is
> unchanged.
> {noformat}
> {!graph from=parentId to=id traversalFilter=name:prefix*
> expandFilter=docType:folder}<root query>
> {noformat}
> h3. Back-compat
> New optional param; no change when it is absent.
>
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]