Example usage for org.apache.solr.client.solrj SolrClient deleteByQuery

List of usage examples for org.apache.solr.client.solrj SolrClient deleteByQuery

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj SolrClient deleteByQuery.

Prototype

public UpdateResponse deleteByQuery(String query) throws SolrServerException, IOException 

Source Link

Document

Deletes documents from the index based on a query

Usage

From source file:org.opencms.search.solr.spellchecking.CmsSpellcheckDictionaryIndexer.java

License:Open Source License

/**
 * Deletes a single document from the Solr client.<p>
 *
 * @param client The SolrClient instance object.
 * @param lang The affected language./*www  . j  a  v  a  2s  .c  om*/
 * @param word The word that should be removed.
 *
 * @throws IOException in case something goes wrong
 * @throws SolrServerException in case something goes wrong
 */
static void deleteDocument(SolrClient client, String lang, String word)
        throws IOException, SolrServerException {

    if ((null == client) || CmsStringUtil.isEmptyOrWhitespaceOnly(lang)
            || CmsStringUtil.isEmptyOrWhitespaceOnly(word)) {
        return;
    }

    // Make sure the parameter holding the word that should be deleted
    // contains just a single word
    if (word.trim().contains(" ")) {
        final String query = String.format("entry_%s:%s", lang, word);
        client.deleteByQuery(query);
    }
}