简体   繁体   English

Solr - 在表单数据输入场景中保存和更新索引时

[英]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.我有一个 web 表单,我想使用下面的示例代码将第一页中的数据保存到索引中。

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? user是否有可能在第一页中执行某些操作并在到达最后一页之前退出?

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.在最后一页,你也保存它 SOLR。

Hope you are also using some backend data source to save the data and solr for search use cases.希望您也使用一些后端数据源来保存数据和solr用于搜索用例。 In this case, it is advisable to update one doc once per operation.在这种情况下,建议每次操作更新一个文档一次。

In case of Cassandra as backend.如果Cassandra作为后端。 there are chances for tombstone when you update a document multiple times.当您多次更新文档时,可能会出现tombstone

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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