Search code examples
javasolrlotus-dominosolrj

Delete index document using solr java api


So here i am using solr for indexing document.

now here is my small part code:

        db = cmd.start();
        new NotesSolrWriter(db, null);
        SolrHelper slrHelp = new SolrHelper();
        QueryResponse res = slrHelp.queryResults("dontKnow1 ", null);
        SolrDocumentList ids = res.getResults();

        count = ids.size();
        System.out.println(count);
        boolean getServer = getServer();
        if (getServer) {
            for (SolrDocument id : ids) {
                System.out.println("See my id " + id.toString());
                FTIserver.deleteById(id.toString());
                FTIserver.commit();
                // FTIserver.commit(true, true);
            }
        }

        QueryResponse res1 = slrHelp.queryResults("dontKnow1 ", null);
        SolrDocumentList ids1 = res1.getResults();
        int count1 = ids1.size();
        System.out.println("before delete::" + count);
        System.out.println("after delete::" + count1);

output:

See my id SolrDocument[{contid=3BAC9EE84691380265257EEB002BAA77, cmrights=[dummy, dummy1, dummy2], dbtype=MAIL, subject=NotesSlrWriter123, [email protected], [email protected], posteddate=Tue Oct 27 13:26:57 IST 2015}]
See my id SolrDocument[{contid=F92F9D8BBD65F36365257EEB0040DEFE, cmrights=[dummy, dummy1, dummy2], dbtype=MAIL, subject=NotesSlrWriter123, [email protected], [email protected], posteddate=Tue Oct 27 17:18:33 IST 2015}]
before delete::2
after delete::2

so here what i am trying to do is getting database then NotesSolrWrite use for indexing my notes document and saving on server, so in res as expected there are two such documents which satisfied query condition and count.size gives number of documents which are selected, and i am printing count's values .

so my problem is now i want to delete this documents from the the server

but i don't know whether i am doing right, after my deleting code still i am getting those documents on server. how to delete that any other way ??

it would be nice if anyone help me


Solution

  • I found the solution. I deleted document by using

    FTIserver.deleteByQuery("dontKnow1");"