Transform a nested collection

87 views
Skip to first unread message

Marc Magnin

unread,
Apr 20, 2014, 5:46:43 AM4/20/14
to rav...@googlegroups.com
Hi all,

I'm trying to filter/transform a nested collection in my results

I have my root document that contains an array called "Illustrations" that contains a "Tags" array.

Here is my document structure :
 
{
  "Nom": "Jack",
  "Illustrations": [
    {
      "Url": "static/illustrations/Illustrateur/106/Sans titre.png",
      "Tags": [
        "blue",
        "red"
      ]
      "Url": "static/illustrations/Illustrateur/107/Sans titre.png",
      "Tags": [
        "green",
        "white"
      ]
    }
  ]}

I want to get root documents with a transformed nested collection that contains the specific searched tags
I'm doing a dynamic query in Lucene to make like :

Illustrations,Tags:"green"

I would like my results to be such as :

{
  "Nom": "Jack",
  "Illustrations": [
    {
      "Url": "static/illustrations/Illustrateur/107/Sans titre.png",
      "Tags": [
        "green",
        "white"
      ]
    }
  ]}

How could I manage that throught the raven studio ? With transformers ?
At the end I would like to query the HTTP API.

Many thanks,
Marc

Oren Eini (Ayende Rahien)

unread,
Apr 22, 2014, 2:31:43 AM4/22/14
to ravendb
You can do this using a transformer that has a Query Input parameter.
But the question is, why are you trying to do this? 



Oren Eini

CEO

Mobile: + 972-52-548-6969

Office:  + 972-4-674-7811

Fax:      + 972-153-4622-7811





--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marc Magnin

unread,
Apr 23, 2014, 2:25:55 PM4/23/14
to rav...@googlegroups.com
Thanks for the answer,

Yes that could look strange. It is in order to get the parent objects "Illustrators" and the filtered collection of "Illustrations". I don't want to get all "Illustrations" of the all "Illustrators".
Can you provide an example of a transformer with such Query Input param ?

Thanks a lot,
Marc

Oren Eini (Ayende Rahien)

unread,
Apr 23, 2014, 3:27:42 PM4/23/14
to ravendb
What happens when you have an illustrator with 1,000 illustrations?

And it is probably something like:

from result in results
select new { result.Name, SelectedIllustration = result.Illustration.FirstOrDefault(x=>x.Name = Query("name")) }

Marc Magnin

unread,
Apr 23, 2014, 6:35:10 PM4/23/14
to rav...@googlegroups.com
Thanks for that!

Yes I will implement something like paging.
I'm trying to do such as :

from result in results
select new { result.Nom, Illustrations = result.Illustrations.Take(3)}

But I get this :

 System.InvalidOperationException: The transform results function failed.
Doc 'illustrateur/169', Error: 'Raven.Abstractions.Linq.DynamicList' does not contain a definition for 'Take'

Oren Eini (Ayende Rahien)

unread,
Apr 23, 2014, 11:13:00 PM4/23/14
to ravendb
That is a bug, can you create an issue?


Marc Magnin

unread,
Apr 24, 2014, 4:05:57 AM4/24/14
to rav...@googlegroups.com
Done here :

Thanks for you quick reply !
Reply all
Reply to author
Forward
0 new messages