Re-index object with new fields

177 views Asked by At

It seems like as long as the id field is maintained, its super easy to re-index a document by simply calling Index(), but is there a way to given an object was updated and new fields were added, to have it include these new fields in the index?

I'm not explicitly creating any indexing, but rather just telling it to index these objects in this index itself. I've been able to delete the document and reindex and it does exactly what I'd expect. (I know theres no magic just update all these documents with a this new field, but if I knew "schema" changed, I could have a manual process handle this).

1

There are 1 answers

2
danvasiloiu On BEST ANSWER

if you want to update you can do this:

        var response = _Instance.Update<BusinessElastic, object>(u => u
             .Index(elasticSearchIndex)
             .Type("business")
             .Id(result.Hits.FirstOrDefault().Id)
             .Doc(new Document {Column1="", Column2=""})
             .DocAsUpsert()
         );