Can SOLR perform an UPSERT?

后端 未结 2 714
刺人心
刺人心 2021-01-19 11:20

I\'ve been attempting to do the equivalent of an UPSERT (insert or update if already exists) in solr. I only know what does not work and the solr/lucene documentation I hav

2条回答
  •  失恋的感觉
    2021-01-19 11:54

    Solr does not support UPSERT mechanics out of the box. You can create a record or you can update a record and syntax is different.

    And if you update the record you must make sure all your other pre-inserted fields are stored (not just indexed). Under the covers, an update creates a completely new record just pre-populated with previously stored values. But that functionality if very deep in (probably in Lucene itself).

    Have you looked at DataImportHandler? You reverse the control flow (start from Solr), but it does have support for checking which records need to be updated and which records need to be created.

    Or you can just run a solr query like http://solr.example.com:8983/solr/select?q=id%3A(ID1+ID2+ID3)&fl=id&wt=csv where you ask Solr to look for your ID records and return only ID of records it does find. Then, you could post-process that to segment your Updates and Inserts.

提交回复
热议问题