How to update data in SOLR? -


hi have solr collection named assetlocalus contains data.

[ {   "assetid": "1-213z-9335",   "availability": 1 }, {    "assetid": "1-213z-1789",      "availability": 2     },     {         "assetid": "1-213z-3452",         "availability": 3      }        ] 

i want update availability based on assetid '1-213z-9335' in solr.

this java code.

 private solrcrudrepository<asset, string> assetrepository;  @autowired private assetentityrepository assetentityrep;  @autowired public assetrequestserviceimpl(solrcrudrepository<asset, string> assetrepository) {     this.assetrepository = assetrepository; }   @override public serviceresponse<?> processassetrequests(asset asset) {     system.out.println("value of availability is==================:" + asset.getavailability());     asset asset2 = null;     try {         logger.info("performing maintdb save asset id: " + asset.getassetid());         assetentityrep.save(asset.getavailability());         // todo: add error handling         logger.info("performing solr save asset id: " + asset.getassetid());         **asset2 = assetrepository.save(asset);**         // todo: add error handling         return serviceresponse.success(asset2);     } catch (exception exception) {         logger.error(string.format("an error occured while processing asset request due : %s", exception),                 exception);         return serviceresponse.error(asset.class);     } } 

i trying update solr collection data using solrcrudrepository.but everytime hitting api update collection not updating data insering new data collection.

  {     "assetid": "1-213z-9335",    "availability": 10000     } 

earlier collection having 3 records contain 4 records. not update availability based on assetid. add new collection.

what change need make update data in collection based on assetid.

if assetid isn't defined uniquekey collection, duplicate allowed (.. or if want duplicate). if assetid unique key document, define such , let solr update stored document.

the field should defined string field (not text) don't perform tokenization etc. on it.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -