You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by Damiano Albani <da...@gmail.com> on 2021/10/08 07:46:20 UTC
Joining with streaming expressions using hierarchical path
Hello,
I have documents in Solr which I'd like to join, based on properties
related to a hierarchical path.
Here's how it's basically structured:
{
> path: "/books/book1",
> ancestors: ["/", "/books"],
> type: "book",
> title: "Book #1"
> }
>
> {
> path: "/books/book2",
> ancestors: ["/", "/books"],
> type: "book",
> title: "Book #2"
> }
>
=====
{
> path: "/books/book1/chapters/chapter1",
> ancestors: ["/", "/books", "/books/book1", "/books/book1/chapters"],
> type: "chapter",
> number: 1,
> title: "Chapter #1"
> }
>
> {
> path: "/books/book1/chapters/chapter2",
> ancestors: ["/", "/books", "/books/book1", "/books/book1/chapters"],
> type: "chapter",
> number: 2,
> title: "Chapter #2"
> }
>
> {
> path: "/books/book2/chapters/chapter1",
> ancestors: ["/", "/books", "/books/book2", "/books/book2/chapters"],
> type: "chapter",
> number: 1,
> title: "Chapter #1"
> }
>
Using streaming expressions, is there a way I could join those documents,
for example to find all books which have more than 1 chapter? Silly
example, but you get the idea :-)
At first, with the "ancestors" field as a TextField, using
*PathHierarchyTokenizerFactory* as index analyzer, I tried something like:
innerJoin(
> search(
> ... type:chapter where number > 1...
> ),
> search(
> ... type:book ...
> ),
> on="ancestors=path")
>
Unfortunately, Solr complained that "ancestors must have DocValues to use
this feature".
I suppose this is related to https://issues.apache.org/jira/browse/SOLR-8362
.
So I thought, maybe should I turn "ancestors" into a multivalued *StrField*
??
But then the *FieldEqualitor* used for the join criteria doesn't seem to
work for "ancestors=path", given how the comparison is made.
Do I understand this correctly?
Anyway, I couldn't find many examples on how to use streaming expressions,
so I'm probably missing something obvious here.
Thanks for your help.
Regards,
--
Damiano Albani