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 Li Li <fa...@gmail.com> on 2010/07/15 05:16:20 UTC
about warm up
I want to load full text into an external cache, So I added so codes
in newSearcher where I found the warm up takes place. I add my codes
before solr warm up which is configed in solrconfig.xml like this:
<listener event="firstSearcher" class="solr.QuerySenderListener">
<arr name="queries">
...
</arr>
</listener>
public void newSearcher(SolrIndexSearcher newSearcher,
SolrIndexSearcher currentSearcher) {
warmTextCache(newSearcher,warmTextCache,new String[]{"title","content"});
for (NamedList nlst : (List<NamedList>)args.get("queries")) {
}
}
in warmTextCache I need a reader to get some docs
for(int i=0;i<reader.maxDoc();i++){
if(reader.isDeleted(i)) continue;
Document doc=reader.document(i);
String fullText=doc.get("content");
cache.put(i,fullText);
}
So I need a reader, When I contruct a reader by myself like:
IndexReader reader=IndexReader.open(...);
Or by core.getSearcher().get().getReader()
Then it will be very slow when I send a query after warm up
I used jstack and found all of the requests are blocked in SolrCore
line 1000 searcherLock.wait();
// check to see if we can wait for someone else's searcher to be set
if (onDeckSearchers>0 && !forceNew && _searcher==null) {
try {
Line 1000 searcherLock.wait();
} catch (InterruptedException e) {
log.info(SolrException.toStr(e));
}
}
And about 5 minutes later. it's ok.
So How can I get a "safe" reader in this situation?
Re: about warm up
Posted by Chris Hostetter <ho...@fucit.org>.
: I want to load full text into an external cache, So I added so codes
: in newSearcher where I found the warm up takes place. I add my codes
...
: public void newSearcher(SolrIndexSearcher newSearcher,
: SolrIndexSearcher currentSearcher) {
: warmTextCache(newSearcher,warmTextCache,new String[]{"title","content"});
...
: in warmTextCache I need a reader to get some docs
...
: So I need a reader, When I contruct a reader by myself like:
: IndexReader reader=IndexReader.open(...);
: Or by core.getSearcher().get().getReader()
Don't do that -- the readers/searchers are refrenced counted by the
SolrCore, so unless you "release" your refrences cleanly all you are
likely to get into some interesting situations
the newSearcher method you are implementing directly gives you the
SolrIndexSearcher (the "newSearcher" arg) that will be used along with
your cache . why don't you use it to get the reader (the
getReader() method)instead of jumping through these hoops you've been
trying?
-Hoss