Search code examples
javahtmlsolrsolrj

Solrj index string containing html in java


I know how to index a html page I downloaded using:

ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update/extract");

    up.addFile(new File(fileName), solrId);
    up.setParam("literal.id", solrId);
    up.setAction(ACTION.COMMIT, true, true);
    getServer().request(up);

If I have the html page in a string String mystring how can I index it without having to save it to a file and read it again?


Solution

  • Instead of using the addFile method, use addContentStream with a ContentStreamBase.StringStream. This will make the CeontentStreamUpdateRequest pull its data from a String instead of a file.

    Related documentation: