Created
August 24, 2016 14:43
-
-
Save mezzatto/1ce2f5b388a21016b19d4c854538f66c to your computer and use it in GitHub Desktop.
Tracking Update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class TrackingUpdateRequestProcessor extends UpdateRequestProcessor { | |
| private final SchemaField sf; | |
| public static ConcurrentHashMap<BytesRef, Long> changes = new ConcurrentHashMap<>(); | |
| public TrackingUpdateRequestProcessor(SolrQueryRequest req, UpdateRequestProcessor next) { | |
| super(next); | |
| sf = req.getCore().getLatestSchema().getUniqueKeyField(); | |
| } | |
| @Override | |
| public void processAdd(AddUpdateCommand cmd) throws IOException { | |
| BytesRefBuilder b = new BytesRefBuilder(); | |
| sf.getType().readableToIndexed(cmd.getSolrInputDocument().getFieldValue("id").toString(), b); | |
| changes.put(b.get(), 1L); | |
| super.processAdd(cmd); | |
| } | |
| @Override | |
| public void processDelete(DeleteUpdateCommand cmd) throws IOException { | |
| changes.put(cmd.getIndexedId(), 0L); | |
| super.processDelete(cmd); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment