Solr is used to manage lists of indexes.
We have a database containing documents of different types.
Each document type is defined by a list of properties and we want to associate
some of these properties with lists of indexes to help users during query.
For example:
The property contains a text field "desc" may be associated with a field Solr
"desc_en_items.
"Desc_en_items" is a dynamic field solr:
And so on for each property associated with a field Solr.
Each Solr document contains an identifier (stored and indexed) Solr and dynamic
fields. (only indexed)
When adding a document in our database, if needed, we dynamically generate the
document and add it to solr. When a document is deleted from our database we
suppress systematically the solr document "deleteById" (the document can not
exist in solr).
There is only one core (Core0) and the server is embedded.
We use a derived lucli/LuceneMethods.java to browse index.
It seems to me, without being sure, that the problem comes when no list is set
(solr is started but contains no records) in a few days of operation. We have a
database with lists parameterized works for several months without problem.
Here the wrappers to use ...solrj.SolrServer
[code]
public class SolrCoreServer
{
private static Logger log = LoggerFactory.getLogger(SolrCoreServer.class);
private SolrServer server=null;
public SolrCoreServer(CoreContainer container, String coreName)
{
server = new EmbeddedSolrServer( container, coreName );
}
protected SolrServer getSolrServer(){
return server;
}
public void cleanup() throws SolrServerException, IOException {
log.debug("cleanup()");
UpdateResponse rsp = server.deleteByQuery( "*:*" );
log.debug("cleanup():" + rsp.getStatus());
if (rsp.getStatus() != 0)
throw new SolrServerException("cleanup() failed status=" +
rsp.getStatus());
}
public void add(SolrInputDocument doc) throws SolrServerException,
IOException{
log.debug("add(" + doc + ")");
UpdateResponse rsp = server.add(doc);
log.debug("add():" + rsp.getStatus());
if (rsp.getStatus() != 0)
throw new SolrServerException("add() failed status=" +
rsp.getStatus());
}
public void add(Collection docs) throws
SolrServerException, IOException{
log.debug("add(" + docs + ")");
UpdateResponse rsp = server.add(docs);
log.debug("add():" + rsp.getStatus());
if (rsp.getStatus() != 0)
throw new SolrServerException("add() failed status=" +
rsp.getStatus());
}
public void deleteById(String docId) throws SolrServerException, IOException{
log.debug("deleteById(" + docId + ")");
UpdateResponse rsp = server.deleteById(docId);
log.debug("deleteById():" + rsp.getStatus());
if (rsp.getStatus() != 0)
throw new SolrServerException("deleteById() failed status="
+ rsp.getStatus());
}
public void commit() throws SolrServerException, IOException {
log.debug("commit()");
UpdateResponse rsp = server.commit();
log.debug("commit():" + rsp.getStatus());
if (rsp.getStatus() != 0)
throw new SolrServerException("commit() failed status=" +
rsp.getStatus());
}
public void addAndCommit(Collection docs) throws
SolrServerException, IOException{
log.debug("addAndCommit(" + docs + ")");
UpdateRequest req = new UpdateRequest();
req.setAction( UpdateRequest.ACTION.COMMIT, false, false );
req.add( docs );
UpdateResponse rsp = req.process( server );
log.debug("addAndCommit():" + rsp.getStatus());
if (rsp.getStatus() != 0)
throw new SolrServerException("addAndCommit() failed
status=" + rsp.getStatus());
}
public QueryResponse query( SolrQuery query ) throws SolrServerException{
log.debug("query(" + query + ")");
QueryResponse qr = server.query( query );
log.debug("query():" + qr.getStatus());
return qr;
}
public QueryResponse query( String queryString, String sortField,
SolrQuery.ORDER order, Integer maxRows ) throws SolrServerException{
log.debug("query(" + queryString + ")");
SolrQuery query = new SolrQuery();
query.setQuery( queryString );
query.addSortField( sortField, order );
query.setRows(maxRows);
QueryResponse qr = server.query( query );
log.debug("query():" + qr.getStatus());
return qr;
}
}
[/code]
the schema
[code]