Is there a transient kind of annotation for Spring-data-mongodb - spring-data-mongodb

I just changed my springboot from using Postgresql to mongo, i am trying to get the mongodb to leave out a property when storing an object in MongoDB, but the #Transient field doesnt work. Is there a way to do this ?

#Transient is supposed to work with Spring Data MongoDB.
From the Spring Data MongoDB documentation:
#Transient: By default all private fields are mapped to the document,
this annotation excludes the field where it is applied from being
stored in the database
If it isn't working for you, I suggest including your code in your question.
Note that if you forgot to add #Transient and added some data to your database, then later added #Transient to a field, Spring Data Mongo isn't going to go through the database collection and delete that field from all the documents that currently have it, it just won't include that field in any new documents it saves to the collection.

Related

How can I have multiple collections in Solr

Hi I am new to Solr and I'm trying to get my bearings.
Using Solr in my case might not be the best idea or might be a bit overkill but this is just for testing to see how to use it.
I would like to create a database which handles users posts and pages, in mongodb I would have created a collection for users, a collection for post and a collection for pages which would obviously contain the individual documents.
I don't know how would I be able to replicate that in Solr . I have created a core for users which I thought is like a collection in mongodb. To add a post on Pages, do I then create a new core for each or is there another way to separate the data?
Thank you for the advice
Yes you can have separate collection in solr as well.
With the latest version of solr where you can use solr cloud and create multiple collections.
Each collection can handle a separate entity.
Please refer the below links for more details
Solr Collection API
Solr Collection Management

How to change unique key to new field and update all the documents without re-indexing?

I want to change the unique key field of documents to a new field, and update documents without re-indexing. What are the options do we have to achieve this? Solr version 8.2 and using solr cloud.
If you change anything on the schema side, you need to reindex the data.
There is an alternative to it.
But the solr cloud has nice feature that can be used here without restarting the solr server.
Create a new config set.
Make all your changes in the newly created configSet.
Upload the newly created configset as zookeper maintains all your configsets.
Create a new collection using the new configset.
Index your data in new collection.
Once all the data is indexed, create an alias to new collection.
Give the alias name same as the old collection.
All your new request will be redirected to new collection.
Once everything is set you can delete the old collection.

Can I use .NET SDK to create Azure Table datasource for Azure Search index?

I would like to configure datasource including ia. field mapping for json string containing collection.
Yes you can - get the latest Azure Search SDK from nuget.org and use DataSource.AzureTableStorage method.
You no longer need to use field mappings to populate string collection fields - Azure Search will do this for you automatically as long as the strings are formatted as a JSON array of strings. However, should you need field mappings for other reasons, they are available as FieldMappings property of Indexer class.

Spring jpa: add field to #Entity class. Should this result in the automatic addition of a new column in the underlying table?

I have a class that is an entity using spring jpa.
I want to add a new field to this class. A private boolean with getter/setter methods.
I have heard that I should be able to just add the field to the class and spring jpa should add the column to the underlying table on next run.
The behaviour that I am actually seeing is that it throws an error.
Is anyone familiar with this operation? Is it true that spring jpa should handle the column addition automatically?

google app engine: How do I add fields to an existent entity

I have a google app engine app where I would like to extend one of my Entity definitions. How would I ensure existent entity objects get the new fields properly initialized? Would the existent objects, the next time I query them, simply have default values? I'd like to add a StringListProperty.
If you add a new property to your model, existing entities will have the default value for it when you load them, if you supplied a default. They won't show up in queries for that value until you fetch them and store them again, though.
You will have to add the property to all of your existing entities, one by one.
You don't mention which language or API you are using. The exact details of the procedure will vary with your situation.
In general, the safest way to do this is to load up each entity with a API that doesn't validate your entities. In python, you can use Expando models. In java, you can use the low level datastore API. (trying this with JDO or JPA may not work) You now need to iterate through all existing entities. (try the new Mapper API to do this with relatively little fuss). For each entity, you will load it, add your new property, then put/save it back to the datastore. Now you can safely go back to a framework that validates your entities, like JDO or non-expando models.
This method applies to modifying the type of a property or deleting a property as well.

Resources