Facets and collections

58 views
Skip to first unread message

James Crowley

unread,
Jun 30, 2012, 6:34:06 AM6/30/12
to rav...@googlegroups.com
If I have the following:

Event { type:"X", tags: ["tag1","tag2"] }

and an index like this:

from event in doc.events
from tag in event.Tags
select {
event.type
tag
}

using faceted search, I'm getting a count of 2 for type: "x" facet ?
Is this expected? I'm using .As<Event>() on the query, which gives me
distinct events in ToList(), but not for ToFacets(). How do I get it
to count only distinct documents?

Thanks!

James

--

---
James Crowley
CTO, FundApps - a new generation in financial services software -
http://www.fundapps.co/
Founder, developerFusion - the global developer community -
http://www.developerfusion.com/

linkedin: http://linkedin.com/in/jamescrowley
twitter: http://twitter.com/jamescrowley

Matt Warren

unread,
Jun 30, 2012, 12:02:36 PM6/30/12
to rav...@googlegroups.com
inline


On Saturday, 30 June 2012 11:34:06 UTC+1, jamescrowley wrote:
If I have the following:

Event { type:"X", tags: ["tag1","tag2"] }

and an index like this:

from event in doc.events
from tag in event.Tags
select {
   event.type
   tag
}

using faceted search, I'm getting a count of 2 for type: "x" facet ?
Is this expected?

Yeah that's expected, faceted search just takes all the terms in the index and gives you the count of how many times each term occurs
 
I'm using .As<Event>() on the query, which gives me distinct events in ToList(), but not for ToFacets().
How do I get it to count only distinct documents?

Facet search doesn't really make sense alongside As, it works in a different way from other queries.

If you want count of distinct events, you can change your index to this, (it should work)

    from event in doc.events
    select {
       event.type
       event.Tags.SelectMany(t => t)
    }

Thanks!

James

Oren Eini (Ayende Rahien)

unread,
Jun 30, 2012, 1:03:43 PM6/30/12
to rav...@googlegroups.com
Almost, you need:

from event in doc.events 
    select { 
       event.type 
       tag = event.Tags

James Crowley

unread,
Jul 2, 2012, 3:34:58 AM7/2/12
to rav...@googlegroups.com
Thanks - I just skipped right past that option assuming it wouldn't
work! Perhaps stick in a collection to the example on
http://ravendb.net/docs/client-api/faceted-search ?

J
--

Oren Eini (Ayende Rahien)

unread,
Jul 2, 2012, 5:12:44 AM7/2/12
to rav...@googlegroups.com
Matt,
Can you add that doc?

Matt Warren

unread,
Jul 2, 2012, 5:27:20 AM7/2/12
to rav...@googlegroups.com
Yeah I'll update it and send a pull-request sometime in the next few days
Reply all
Reply to author
Forward
0 new messages