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 Dmitry Kan <dm...@gmail.com> on 2011/03/16 13:05:48 UTC

faceting over ngrams

Hello guys. We are using shard'ed solr 1.4 for heavy faceted search over the
trigrams field with about 1 million of entries in the result set and more
than 100 million of entries to facet on in the index. Currently the faceted
search is very slow, taking about 5 minutes per query. Would running on a
cloud with Hadoop make it faster (to seconds) as faceting seems to be a
natural map-reduce task?

Are there any other options to look into before stepping into the cloud?

Please let me know, if you need specific details on the schema / solrconfig
setup or the like.

-- 
Regards,

Dmitry Kan

Re: faceting over ngrams

Posted by Jonathan Rochkind <ro...@jhu.edu>.
I don't know anything about trying to use map-reduce with Solr.

But I can tell you that with about 6 million entries in the result set, 
and around 10 million values to facet on (facetting on a multi-value 
field) -- I still get fine performance in my application. In the worst 
case it can take maybe 800ms for my complete query when nothing useful 
is in the caches, which isn't great, but is FAR from 5 minutes!

Now, 100 million values is an order of magnitude more than 10 million -- 
but it still seems like it ought not to be that slow. Not sure what's 
making it so slow for you.  Could you need more RAM allocated to the 
JVM? I have found that facetting sometimes gets pathologically slow when 
I don't have enough RAM -- even though I'm not getting any OOM errors or 
anything.  Of course, I'm not sure exactly what "enough RAM" is for your 
use case -- in my case I'm giving my JVM about 5G of heap.  I also make 
sure to use facet.method=fc for these high-ordinality fields (forget if 
that's the default in 1.4.1 or not).   I also do some warming queries at 
startup to try and fill the various caches that might be involved in 
facetting -- but I don't entirely understand what I'm doing there, and 
that isn't your problem, because that would only effect the first time 
you did such a facetting query, but you're getting the pathological 5min 
result times on subsequent times too.

I am definitely not an expert in the internals of Solr that effect this 
stuff, I'm just reporting my experience, and from my experience -- your 
experience does not match mine.

Jonathan

On 3/16/2011 8:05 AM, Dmitry Kan wrote:
> Hello guys. We are using shard'ed solr 1.4 for heavy faceted search over the
> trigrams field with about 1 million of entries in the result set and more
> than 100 million of entries to facet on in the index. Currently the faceted
> search is very slow, taking about 5 minutes per query. Would running on a
> cloud with Hadoop make it faster (to seconds) as faceting seems to be a
> natural map-reduce task?
>
> Are there any other options to look into before stepping into the cloud?
>
> Please let me know, if you need specific details on the schema / solrconfig
> setup or the like.
>

Re: faceting over ngrams

Posted by Dmitry Kan <dm...@gmail.com>.
Hi Toke,

Thanks a lot for trying this out. I have to mention, that the facetted
search hits only one specific shard by design, so in general the time to
query a shard directly and through the "proxy" SOLR should be comparable.

Would it be feasible for you to make that field ngram'ed or is it too much
worry for you?

I'll check out the direct query and let you know.

On Wed, Mar 16, 2011 at 5:51 PM, Toke Eskildsen <te...@statsbiblioteket.dk>wrote:

> On Wed, 2011-03-16 at 13:05 +0100, Dmitry Kan wrote:
> > Hello guys. We are using shard'ed solr 1.4 for heavy faceted search over
> the
> > trigrams field with about 1 million of entries in the result set and more
> > than 100 million of entries to facet on in the index. Currently the
> faceted
> > search is very slow, taking about 5 minutes per query.
>
> I tried creating an index with 1M documents, each with 100 unique terms
> in a field. A search for "*:*" with a facet request for the first 1M
> entries in the field took about 20 seconds for the first call and about
> 1-1½ second for each subsequent call. This was with Solr trunk. The
> complexity of my setup is no doubt a lot simpler and lighter than yours,
> but 5 minutes sounds excessive.
>
> My guess is that your performance problem is due to the merging process.
> Could you try measuring the performance of a direct request to a single
> shard? If that is satisfactory, going to the cloud would not solve your
> problem. If you really need 1M entries in your result set, you would be
> better of investigating whether your index can be in a single instance.
>
>


-- 
Regards,

Dmitry Kan

Re: faceting over ngrams

Posted by Jonathan Rochkind <ro...@jhu.edu>.
Oh, doc count over 100M is a very different thing than doc count about 
1M. In your original message you said "I tried creating an index with 1M 
documents, each with 100 unique terms in a field." If you instead have 
100M documents, your use is a couple orders of magnitude larger than mine.

It also occurs to me that while I have around 3 million documents, and 
probably up to 50 million or so unique values in the multi-valued 
facetted field -- each document only has 3-10 values, not 100 each. So 
that may also be a difference that effects the facetting algorithm to 
your detriment, not sure.

Prior to Solr 1.4, it was pretty much impossible to facet over 1 
million+ unique values at all, now it works wonderfully in many use 
cases, but you may have found one that's still too much for it.

It also raises my curiosity as to why you'd want to facet over a 
n-grammed field to begin with, that's definitely not an ordinary use 
case. Perhaps there is some way to do what you need without facetting? 
But you probably know what you're doing.

Jonathan

On 3/16/2011 2:25 PM, Dmitry Kan wrote:
> Hi Jonathan,
>
> Thanks for sharing useful bits. Each shard has 16G of heap. Unless I 
> do something fundamentally wrong in the SOLR configuration, I have to 
> admit, that counting ngrams up to trigrams across whole set of shard's 
> documents is pretty intensive task, as each ngram can occur anywhere 
> in the index and SOLR most probably doesn't precompute the cumulative 
> count of it. I'll try querying with facet.method=fc, thanks for that.
>
> By the way, the trigrams are defined like this:
>
> <fieldType name="shingle_text_trigram" class="solr.TextField" 
> positionIncrementGap="100">
> <analyzer>
> <tokenizer class="solr.LowerCaseTokenizerFactory"/>
> <filter class="solr.ShingleFilterFactory" maxShingleSize="3" 
> outputUnigrams="true"/>
> </analyzer>
> </fieldType>
>
> For the sharding -- I decided to go with it, when the index size 
> approached half a terabyte and doc count went over 100M, I thought it 
> would help us scale better. I also maintain good level of caching, and 
> so far the faceting over normal string fields (no ngrams) performed 
> really well (around 1 sec).
>
>
> On Wed, Mar 16, 2011 at 6:23 PM, Jonathan Rochkind <rochkind@jhu.edu 
> <ma...@jhu.edu>> wrote:
>
>     Ah, wait, you're doing sharding?  Yeah, I am NOT doing sharding,
>     so that could explain our different experiences.  It seems like
>     sharding definitely has trade-offs, makes some things faster and
>     other things slower. So far I've managed to avoid it, in the
>     interest of keeping things simpler and easier to understand (for
>     me, the developer/Solr manager), thinking that sharding is also a
>     somewhat less mature feature.
>
>     With only 1M documents.... are you sure you need sharding at all?
>      You could still use replication to "scale out" for volume,
>     sharding seems more about scaling for number of documents (or
>     total bytes) in your index.  1M documents is not very large, for
>     Solr, in general.
>
>     Jonathan
>
>
>     On 3/16/2011 11:51 AM, Toke Eskildsen wrote:
>
>         On Wed, 2011-03-16 at 13:05 +0100, Dmitry Kan wrote:
>
>             Hello guys. We are using shard'ed solr 1.4 for heavy
>             faceted search over the
>             trigrams field with about 1 million of entries in the
>             result set and more
>             than 100 million of entries to facet on in the index.
>             Currently the faceted
>             search is very slow, taking about 5 minutes per query.
>
>         I tried creating an index with 1M documents, each with 100
>         unique terms
>         in a field. A search for "*:*" with a facet request for the
>         first 1M
>         entries in the field took about 20 seconds for the first call
>         and about
>         1-1½ second for each subsequent call. This was with Solr
>         trunk. The
>         complexity of my setup is no doubt a lot simpler and lighter
>         than yours,
>         but 5 minutes sounds excessive.
>
>         My guess is that your performance problem is due to the
>         merging process.
>         Could you try measuring the performance of a direct request to
>         a single
>         shard? If that is satisfactory, going to the cloud would not
>         solve your
>         problem. If you really need 1M entries in your result set, you
>         would be
>         better of investigating whether your index can be in a single
>         instance.
>
>
>
>
> -- 
> Regards,
>
> Dmitry Kan

Re: faceting over ngrams

Posted by Dmitry Kan <dm...@gmail.com>.
Hi Jonathan,

Thanks for sharing useful bits. Each shard has 16G of heap. Unless I do
something fundamentally wrong in the SOLR configuration, I have to admit,
that counting ngrams up to trigrams across whole set of shard's documents is
pretty intensive task, as each ngram can occur anywhere in the index and
SOLR most probably doesn't precompute the cumulative count of it. I'll try
querying with facet.method=fc, thanks for that.

By the way, the trigrams are defined like this:

<fieldType name="shingle_text_trigram" class="solr.TextField"
positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.LowerCaseTokenizerFactory"/>
<filter class="solr.ShingleFilterFactory" maxShingleSize="3"
outputUnigrams="true"/>
</analyzer>
</fieldType>

For the sharding -- I decided to go with it, when the index size approached
half a terabyte and doc count went over 100M, I thought it would help us
scale better. I also maintain good level of caching, and so far the faceting
over normal string fields (no ngrams) performed really well (around 1 sec).


On Wed, Mar 16, 2011 at 6:23 PM, Jonathan Rochkind <ro...@jhu.edu> wrote:

> Ah, wait, you're doing sharding?  Yeah, I am NOT doing sharding, so that
> could explain our different experiences.  It seems like sharding definitely
> has trade-offs, makes some things faster and other things slower. So far
> I've managed to avoid it, in the interest of keeping things simpler and
> easier to understand (for me, the developer/Solr manager), thinking that
> sharding is also a somewhat less mature feature.
>
> With only 1M documents.... are you sure you need sharding at all?  You
> could still use replication to "scale out" for volume, sharding seems more
> about scaling for number of documents (or total bytes) in your index.  1M
> documents is not very large, for Solr, in general.
>
> Jonathan
>
>
> On 3/16/2011 11:51 AM, Toke Eskildsen wrote:
>
>> On Wed, 2011-03-16 at 13:05 +0100, Dmitry Kan wrote:
>>
>>> Hello guys. We are using shard'ed solr 1.4 for heavy faceted search over
>>> the
>>> trigrams field with about 1 million of entries in the result set and more
>>> than 100 million of entries to facet on in the index. Currently the
>>> faceted
>>> search is very slow, taking about 5 minutes per query.
>>>
>> I tried creating an index with 1M documents, each with 100 unique terms
>> in a field. A search for "*:*" with a facet request for the first 1M
>> entries in the field took about 20 seconds for the first call and about
>> 1-1½ second for each subsequent call. This was with Solr trunk. The
>> complexity of my setup is no doubt a lot simpler and lighter than yours,
>> but 5 minutes sounds excessive.
>>
>> My guess is that your performance problem is due to the merging process.
>> Could you try measuring the performance of a direct request to a single
>> shard? If that is satisfactory, going to the cloud would not solve your
>> problem. If you really need 1M entries in your result set, you would be
>> better of investigating whether your index can be in a single instance.
>>
>>


-- 
Regards,

Dmitry Kan

Re: faceting over ngrams

Posted by Jonathan Rochkind <ro...@jhu.edu>.
Ah, wait, you're doing sharding?  Yeah, I am NOT doing sharding, so that 
could explain our different experiences.  It seems like sharding 
definitely has trade-offs, makes some things faster and other things 
slower. So far I've managed to avoid it, in the interest of keeping 
things simpler and easier to understand (for me, the developer/Solr 
manager), thinking that sharding is also a somewhat less mature feature.

With only 1M documents.... are you sure you need sharding at all?  You 
could still use replication to "scale out" for volume, sharding seems 
more about scaling for number of documents (or total bytes) in your 
index.  1M documents is not very large, for Solr, in general.

Jonathan

On 3/16/2011 11:51 AM, Toke Eskildsen wrote:
> On Wed, 2011-03-16 at 13:05 +0100, Dmitry Kan wrote:
>> Hello guys. We are using shard'ed solr 1.4 for heavy faceted search over the
>> trigrams field with about 1 million of entries in the result set and more
>> than 100 million of entries to facet on in the index. Currently the faceted
>> search is very slow, taking about 5 minutes per query.
> I tried creating an index with 1M documents, each with 100 unique terms
> in a field. A search for "*:*" with a facet request for the first 1M
> entries in the field took about 20 seconds for the first call and about
> 1-1½ second for each subsequent call. This was with Solr trunk. The
> complexity of my setup is no doubt a lot simpler and lighter than yours,
> but 5 minutes sounds excessive.
>
> My guess is that your performance problem is due to the merging process.
> Could you try measuring the performance of a direct request to a single
> shard? If that is satisfactory, going to the cloud would not solve your
> problem. If you really need 1M entries in your result set, you would be
> better of investigating whether your index can be in a single instance.
>

Re: faceting over ngrams

Posted by Toke Eskildsen <te...@statsbiblioteket.dk>.
On Wed, 2011-03-16 at 13:05 +0100, Dmitry Kan wrote:
> Hello guys. We are using shard'ed solr 1.4 for heavy faceted search over the
> trigrams field with about 1 million of entries in the result set and more
> than 100 million of entries to facet on in the index. Currently the faceted
> search is very slow, taking about 5 minutes per query.

I tried creating an index with 1M documents, each with 100 unique terms
in a field. A search for "*:*" with a facet request for the first 1M
entries in the field took about 20 seconds for the first call and about
1-1½ second for each subsequent call. This was with Solr trunk. The
complexity of my setup is no doubt a lot simpler and lighter than yours,
but 5 minutes sounds excessive.

My guess is that your performance problem is due to the merging process.
Could you try measuring the performance of a direct request to a single
shard? If that is satisfactory, going to the cloud would not solve your
problem. If you really need 1M entries in your result set, you would be
better of investigating whether your index can be in a single instance.


Re: faceting over ngrams

Posted by Dmitry Kan <dm...@gmail.com>.
Hi Yonik,

I have ran the queries against single index solr with only 16M documents.
After attaching facet.method=fc the results seemed to come faster (first two
queries below), but still not fast enough.

Here are the fieldValueCache stats:

(facet.limit=1000000&facet.mincount=5&facet.method=fc, 542094 hits, 1 min)
--> smallest result set

*name: *fieldValueCache  *class: *org.apache.solr.search.FastLRUCache  *
version: *1.0  *description: *Concurrent LRU Cache(maxSize=10000,
initialSize=10, minSize=9000, acceptableSize=9500, cleanupThread=false)  *
stats: *lookups : 400
hits : 396
hitratio : 0.99
inserts : 1
evictions : 0
size : 1
warmupTime : 0
cumulative_lookups : 400
cumulative_hits : 396
cumulative_hitratio : 0.99
cumulative_inserts : 1
cumulative_evictions : 0
item_shingleContent_trigram :
{field=shingleContent_trigram,memSize=1786355392,tindexSize=17977426,time=662387,phase1=654707,nTerms=53492050,bigTerms=38,termInstances=602090958,uses=397}

(facet.limit=1000000&facet.mincount=5&facet.method=fc, 2837589 hits, 3 min 8
s) --> largest result set

*name: *fieldValueCache  *class: *org.apache.solr.search.FastLRUCache  *
version: *1.0  *description: *Concurrent LRU Cache(maxSize=10000,
initialSize=10, minSize=9000, acceptableSize=9500, cleanupThread=false)  *
stats: *lookups : 401
hits : 397
hitratio : 0.99
inserts : 1
evictions : 0
size : 1
warmupTime : 0
cumulative_lookups : 401
cumulative_hits : 397
cumulative_hitratio : 0.99
cumulative_inserts : 1
cumulative_evictions : 0
item_shingleContent_trigram :
{field=shingleContent_trigram,memSize=1786355392,tindexSize=17977426,time=662387,phase1=654707,nTerms=53492050,bigTerms=38,termInstances=602090958,uses=398}


On Wed, Mar 16, 2011 at 9:46 PM, Yonik Seeley <yo...@lucidimagination.com>wrote:

> On Wed, Mar 16, 2011 at 8:05 AM, Dmitry Kan <dm...@gmail.com> wrote:
> > Hello guys. We are using shard'ed solr 1.4 for heavy faceted search over
> the
> > trigrams field with about 1 million of entries in the result set and more
> > than 100 million of entries to facet on in the index. Currently the
> faceted
> > search is very slow, taking about 5 minutes per query. Would running on a
> > cloud with Hadoop make it faster (to seconds) as faceting seems to be a
> > natural map-reduce task?
>
> How many indexed tokens does each document have (for the field you are
> faceting on) on average?
> How many unique tokens are indexed in that field over the complete index?
>
> Or you could go to the admin/stats page and cut-n-paste the
> fieldValueCache entry after your faceting request - it should contain
> most of the info to further analyze this.
>
> -Yonik
> http://lucidimagination.com
>



-- 
Regards,

Dmitry Kan

Re: faceting over ngrams

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Wed, Mar 16, 2011 at 8:05 AM, Dmitry Kan <dm...@gmail.com> wrote:
> Hello guys. We are using shard'ed solr 1.4 for heavy faceted search over the
> trigrams field with about 1 million of entries in the result set and more
> than 100 million of entries to facet on in the index. Currently the faceted
> search is very slow, taking about 5 minutes per query. Would running on a
> cloud with Hadoop make it faster (to seconds) as faceting seems to be a
> natural map-reduce task?

How many indexed tokens does each document have (for the field you are
faceting on) on average?
How many unique tokens are indexed in that field over the complete index?

Or you could go to the admin/stats page and cut-n-paste the
fieldValueCache entry after your faceting request - it should contain
most of the info to further analyze this.

-Yonik
http://lucidimagination.com