Search code examples
solratomic

Solr stores map instead of atomic update


When trying to perform an atomic update of "fields", I end up with a map stored there (like 'add=something') instead of its atomic add operation. The field is stored, docValues and multiValued. Can't get: what I'm doing wrong?

    ...
    final SolrQuery query = new SolrQuery("tag:(" + term + ')');

    final AddUpdateCommand addUpdateCommand;
    final SolrQueryRequest queryRequest = new LocalSolrQueryRequest(targetCore, query)
    addUpdateCommand = new AddUpdateCommand(queryRequest);

    final SolrInputDocument document = new SolrInputDocument();
    document.addField("tag", term);
    document.addField("fields", ImmutableMap.of("add", fieldName));

    addUpdateCommand.solrDoc = document;
    assert AtomicUpdateDocumentMerger.isAtomicUpdate(addUpdateCommand);

    updateHandler.addDoc(addUpdateCommand);
    ...

Solution

  • I actually ended up with simply storing a List instead of Map, manually updating the contents of necessary fields. By some reason atomic updates do not work.