You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by kenneth hansen <ke...@hotmail.co.uk> on 2011/10/10 15:47:07 UTC
Newbie: document count and facets
hello,
I'm quite new to Solr and are trying to get a grip on it all. I'm currently reading and enjoying the "Solr 1.4 Enterprise Search Server" book. I'm trying and failing and need some advise on the following.
given the following schema for "subscriptions"
<schema name="example" version="1.1">
<types>
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="date" class="solr.TrieDateField" omitNorms="true" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true"/>
</types>
<fields>
<field name="subscriptionId" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
<field name="accountId" type="string" indexed="true" stored="true" multiValued="false"/>
<field name="isClosed" type="boolean" indexed="true" stored="true" multiValued="false"/>
<field name="createdDate" type="date" indexed="true" stored="true" multiValued="false"/>
</fields>
<uniqueKey>subscriptionId</uniqueKey>
</schema>
I would like to group per accountId, and facet the isClosed per accountId. In addition, I would like to see the number of created subscriptions since a given date. Would that be possible? I just can't figure out how to do the grouping...
Something like this:
Number of subscriptions for accountId 12345: 100
Created subscriptions since 01/01/2011: 70
Closed subscriptions: 10
any advise would be highly appreciated
regards,
Kenneth
Re: Newbie: document count and facets
Posted by Erick Erickson <er...@gmail.com>.
Very close, but think about using
facet.query rather than faceting on
a date range, something like
facet.query=createDate:[NOW/DAYS-1MONTHS TO NOW]
&facet.query=isClosed:yes
The problem with date range is that you'll be getting multiple
entries back....
On Tue, Oct 11, 2011 at 8:25 AM, kenneth hansen <ke...@hotmail.co.uk> wrote:
>
> ok,
> I'll try to answer this myself. Would this be correct to give me the data I need?
>
> http://localhost:8080/solr-3.3.0/select/?
> q=accountId:12345
> &start=0
> &rows=10
> &indent=on
> &facet=true
> &facet.date=createdDate
> &f.createdDate.facet.date.start=NOW/DAYS-1MONTHS
> &f.createdDate.facet.date.end=NOW
> &f.createdDate.facet.date.gap=%2b1MONTH
> &facet.field=isClosed
> &facet.mincount=1
>
>
>
>> From: kenhans@hotmail.co.uk
>> To: solr-user@lucene.apache.org
>> Subject: Newbie: document count and facets
>> Date: Mon, 10 Oct 2011 14:47:07 +0100
>>
>>
>> hello,
>> I'm quite new to Solr and are trying to get a grip on it all. I'm currently reading and enjoying the "Solr 1.4 Enterprise Search Server" book. I'm trying and failing and need some advise on the following.
>>
>> given the following schema for "subscriptions"
>>
>> <schema name="example" version="1.1">
>> <types>
>> <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
>> <fieldType name="date" class="solr.TrieDateField" omitNorms="true" precisionStep="0" positionIncrementGap="0"/>
>> <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true"/>
>> </types>
>> <fields>
>> <field name="subscriptionId" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
>> <field name="accountId" type="string" indexed="true" stored="true" multiValued="false"/>
>> <field name="isClosed" type="boolean" indexed="true" stored="true" multiValued="false"/>
>> <field name="createdDate" type="date" indexed="true" stored="true" multiValued="false"/>
>> </fields>
>> <uniqueKey>subscriptionId</uniqueKey>
>> </schema>
>>
>> I would like to group per accountId, and facet the isClosed per accountId. In addition, I would like to see the number of created subscriptions since a given date. Would that be possible? I just can't figure out how to do the grouping...
>>
>> Something like this:
>>
>> Number of subscriptions for accountId 12345: 100
>> Created subscriptions since 01/01/2011: 70
>> Closed subscriptions: 10
>>
>> any advise would be highly appreciated
>>
>> regards,
>> Kenneth
>
RE: Newbie: document count and facets
Posted by kenneth hansen <ke...@hotmail.co.uk>.
ok,
I'll try to answer this myself. Would this be correct to give me the data I need?
http://localhost:8080/solr-3.3.0/select/?
q=accountId:12345
&start=0
&rows=10
&indent=on
&facet=true
&facet.date=createdDate
&f.createdDate.facet.date.start=NOW/DAYS-1MONTHS
&f.createdDate.facet.date.end=NOW
&f.createdDate.facet.date.gap=%2b1MONTH
&facet.field=isClosed
&facet.mincount=1
> From: kenhans@hotmail.co.uk
> To: solr-user@lucene.apache.org
> Subject: Newbie: document count and facets
> Date: Mon, 10 Oct 2011 14:47:07 +0100
>
>
> hello,
> I'm quite new to Solr and are trying to get a grip on it all. I'm currently reading and enjoying the "Solr 1.4 Enterprise Search Server" book. I'm trying and failing and need some advise on the following.
>
> given the following schema for "subscriptions"
>
> <schema name="example" version="1.1">
> <types>
> <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
> <fieldType name="date" class="solr.TrieDateField" omitNorms="true" precisionStep="0" positionIncrementGap="0"/>
> <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true"/>
> </types>
> <fields>
> <field name="subscriptionId" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
> <field name="accountId" type="string" indexed="true" stored="true" multiValued="false"/>
> <field name="isClosed" type="boolean" indexed="true" stored="true" multiValued="false"/>
> <field name="createdDate" type="date" indexed="true" stored="true" multiValued="false"/>
> </fields>
> <uniqueKey>subscriptionId</uniqueKey>
> </schema>
>
> I would like to group per accountId, and facet the isClosed per accountId. In addition, I would like to see the number of created subscriptions since a given date. Would that be possible? I just can't figure out how to do the grouping...
>
> Something like this:
>
> Number of subscriptions for accountId 12345: 100
> Created subscriptions since 01/01/2011: 70
> Closed subscriptions: 10
>
> any advise would be highly appreciated
>
> regards,
> Kenneth