简体   繁体   中英

Solr - When Save and Update an Index In Form Data Entry scenarios

I have a web form from which I want to save the data from the very first page to an index by using this sample code below.

Startup.Init<SomeModel>("http://localhost:8983/solr/somemodels");
var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Quote>>();
solr.Add(new SomeModel() {Id=1001; Content="Some Content"});
solr.Commit();

On the very last page, the user is given a chance to change/update his entries on the form. Should I also use this line of code?

solr.Add(new SomeModel() {Id=1001; Content="New Content"});

Also, is this a good practice - having indexes updated in this fashion?

You can consider the below things.

  1. Is there any chance that user does something in the first page and drops off in before reaching the last page?

If this is valid scenario and data loss is not acceptable, you should save the data.

  1. If you only want to save the data when use reaches at the last page, then you should do the below.

You should save the data which you want to be saved between pages. At the last page, you save it too SOLR.

Hope you are also using some backend data source to save the data and solr for search use cases. In this case, it is advisable to update one doc once per operation.

In case of Cassandra as backend. there are chances for tombstone when you update a document multiple times.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM