writing mongo db match operation in spring boot for an empty array [duplicate] The 2019 Stack Overflow Developer Survey Results Are InFind MongoDB records where array field is not emptyJava return an empty listhow to search the array with no empty value from mongodb in java?Spring JPA Auditing empty createdByHow to configure port for a Spring Boot applicationHow to log SQL statements in Spring Boot?Using RowMapper and JdbcTemplate got NullPointerExceptionSpring Boot - Loading Initial DataSpring boot security consider case insensitive username check for loginspring boot mongo multiple databaseSpring boot security cannot log in after invalid credentialsMongodb inner join in java spring using AggregationOperation :Error [The 'cursor' option is required, except for aggregate with the explain argument]OneToMany Relationship with 3 entity class using JPA and spring boot

How do I free up internal storage if I don't have any apps downloaded?

Why are there uneven bright areas in this photo of black hole?

How to notate time signature switching consistently every measure

What information about me do stores get via my credit card?

Correct punctuation for showing a character's confusion

Likelihood that a superbug or lethal virus could come from a landfill

Can withdrawing asylum be illegal?

If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?

Accepted by European university, rejected by all American ones I applied to? Possible reasons?

How much of the clove should I use when using big garlic heads?

What is preventing me from simply constructing a hash that's lower than the current target?

How did passengers keep warm on sail ships?

Finding the area between two curves with Integrate

How to type a long/em dash `—`

Time travel alters history but people keep saying nothing's changed

How can I add encounters in the Lost Mine of Phandelver campaign without giving PCs too much XP?

"as much details as you can remember"

Can an undergraduate be advised by a professor who is very far away?

Why was M87 targeted for the Event Horizon Telescope instead of Sagittarius A*?

What does もの mean in this sentence?

How to translate "being like"?

What is this sharp, curved notch on my knife for?

Unitary representations of finite groups over finite fields

Are there any other methods to apply to solving simultaneous equations?



writing mongo db match operation in spring boot for an empty array [duplicate]



The 2019 Stack Overflow Developer Survey Results Are InFind MongoDB records where array field is not emptyJava return an empty listhow to search the array with no empty value from mongodb in java?Spring JPA Auditing empty createdByHow to configure port for a Spring Boot applicationHow to log SQL statements in Spring Boot?Using RowMapper and JdbcTemplate got NullPointerExceptionSpring Boot - Loading Initial DataSpring boot security consider case insensitive username check for loginspring boot mongo multiple databaseSpring boot security cannot log in after invalid credentialsMongodb inner join in java spring using AggregationOperation :Error [The 'cursor' option is required, except for aggregate with the explain argument]OneToMany Relationship with 3 entity class using JPA and spring boot



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1
















This question already has an answer here:



  • Find MongoDB records where array field is not empty

    10 answers



  • how to search the array with no empty value from mongodb in java?

    1 answer



  • Java return an empty list

    5 answers



how to write the below mnonodb query in the matchoperation I have tried the options $exists but did not get the desired results hence raised it.
so the solution is definitely different to the links referred to mark it as duplicate.



db.rsc_installtion_status.aggregate([
$lookup :

from:"vmdetails",
localField:"hostname",
foreignField:"hostname" ,
as:"rscinstall"

,

$match: "rscinstall": $eq: []

])


so far the code which i have is



LookupOperation lookupOperation = LookupOperation.newLookup().from("vmdetails").localField("hostname").foreignField("hostname").as("rscInstall");


i am not able to put the match criteria



 MatchOperation matchOperation = Aggregation.match(Criteria.where("rscinstall").equals(null));


Updated Answer -- I have tried the options which



 String lookupquery = "$lookup :from:"vmdetails",localField:"hostname",foreignField:"hostname"as:"rscinstall"";
String matchquery = " $match: "rscinstall": $eq: [] ";
String projectquery = "$project:"rscinstall":0";
String outquery = "$out:to:"RscInstallArchive", mode: "replaceDocuments"";

AggregationOperation lookupOpertaion = new CustomProjectAggregationOperation(lookupquery);
AggregationOperation matchOperation = new CustomProjectAggregationOperation(matchquery);
AggregationOperation projectOperation = new CustomProjectAggregationOperation(projectquery);
AggregationOperation outOperation = new CustomProjectAggregationOperation(outquery);
Aggregation aggregation = Aggregation.newAggregation(lookupOpertaion, matchOperation,projectOperation);


Custom Aggregation



public class CustomProjectAggregationOperation implements AggregationOperation 

private String jsonOperation;

public CustomProjectAggregationOperation(String jsonOperation)
this.jsonOperation = jsonOperation;


@Override
public Document toDocument(AggregationOperationContext aggregationOperationContext)
return aggregationOperationContext.getMappedObject(Document.parse(jsonOperation));











share|improve this question















marked as duplicate by Neil Lunn mongodb-query
Users with the  mongodb-query badge can single-handedly close mongodb-query questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 22 at 6:16


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • Basically anything can always be represented with Document or BasicDBObject depending on the sping-mongo version used and it's underlying Java driver implementation. Probably the most simple and direct would be .ne(Collections.EMPTY_LIST) or ANY actual constructor of an "empty list". It's usually very acceptable to look for NOT fieldname.0 ( i.e $exists with false ) where 0 is the index position of the first array element. As long as you are certain you do not store an object with keys of 0 instead of an array, it's probably the more performant and flexible option

    – Neil Lunn
    Mar 22 at 6:23











  • @NeilLunn I have used the options which u mentioned but those didn't work. the questions may be similar but the solution is different .

    – Abrar Ahamed
    Mar 22 at 13:18

















-1
















This question already has an answer here:



  • Find MongoDB records where array field is not empty

    10 answers



  • how to search the array with no empty value from mongodb in java?

    1 answer



  • Java return an empty list

    5 answers



how to write the below mnonodb query in the matchoperation I have tried the options $exists but did not get the desired results hence raised it.
so the solution is definitely different to the links referred to mark it as duplicate.



db.rsc_installtion_status.aggregate([
$lookup :

from:"vmdetails",
localField:"hostname",
foreignField:"hostname" ,
as:"rscinstall"

,

$match: "rscinstall": $eq: []

])


so far the code which i have is



LookupOperation lookupOperation = LookupOperation.newLookup().from("vmdetails").localField("hostname").foreignField("hostname").as("rscInstall");


i am not able to put the match criteria



 MatchOperation matchOperation = Aggregation.match(Criteria.where("rscinstall").equals(null));


Updated Answer -- I have tried the options which



 String lookupquery = "$lookup :from:"vmdetails",localField:"hostname",foreignField:"hostname"as:"rscinstall"";
String matchquery = " $match: "rscinstall": $eq: [] ";
String projectquery = "$project:"rscinstall":0";
String outquery = "$out:to:"RscInstallArchive", mode: "replaceDocuments"";

AggregationOperation lookupOpertaion = new CustomProjectAggregationOperation(lookupquery);
AggregationOperation matchOperation = new CustomProjectAggregationOperation(matchquery);
AggregationOperation projectOperation = new CustomProjectAggregationOperation(projectquery);
AggregationOperation outOperation = new CustomProjectAggregationOperation(outquery);
Aggregation aggregation = Aggregation.newAggregation(lookupOpertaion, matchOperation,projectOperation);


Custom Aggregation



public class CustomProjectAggregationOperation implements AggregationOperation 

private String jsonOperation;

public CustomProjectAggregationOperation(String jsonOperation)
this.jsonOperation = jsonOperation;


@Override
public Document toDocument(AggregationOperationContext aggregationOperationContext)
return aggregationOperationContext.getMappedObject(Document.parse(jsonOperation));











share|improve this question















marked as duplicate by Neil Lunn mongodb-query
Users with the  mongodb-query badge can single-handedly close mongodb-query questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 22 at 6:16


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • Basically anything can always be represented with Document or BasicDBObject depending on the sping-mongo version used and it's underlying Java driver implementation. Probably the most simple and direct would be .ne(Collections.EMPTY_LIST) or ANY actual constructor of an "empty list". It's usually very acceptable to look for NOT fieldname.0 ( i.e $exists with false ) where 0 is the index position of the first array element. As long as you are certain you do not store an object with keys of 0 instead of an array, it's probably the more performant and flexible option

    – Neil Lunn
    Mar 22 at 6:23











  • @NeilLunn I have used the options which u mentioned but those didn't work. the questions may be similar but the solution is different .

    – Abrar Ahamed
    Mar 22 at 13:18













-1












-1








-1









This question already has an answer here:



  • Find MongoDB records where array field is not empty

    10 answers



  • how to search the array with no empty value from mongodb in java?

    1 answer



  • Java return an empty list

    5 answers



how to write the below mnonodb query in the matchoperation I have tried the options $exists but did not get the desired results hence raised it.
so the solution is definitely different to the links referred to mark it as duplicate.



db.rsc_installtion_status.aggregate([
$lookup :

from:"vmdetails",
localField:"hostname",
foreignField:"hostname" ,
as:"rscinstall"

,

$match: "rscinstall": $eq: []

])


so far the code which i have is



LookupOperation lookupOperation = LookupOperation.newLookup().from("vmdetails").localField("hostname").foreignField("hostname").as("rscInstall");


i am not able to put the match criteria



 MatchOperation matchOperation = Aggregation.match(Criteria.where("rscinstall").equals(null));


Updated Answer -- I have tried the options which



 String lookupquery = "$lookup :from:"vmdetails",localField:"hostname",foreignField:"hostname"as:"rscinstall"";
String matchquery = " $match: "rscinstall": $eq: [] ";
String projectquery = "$project:"rscinstall":0";
String outquery = "$out:to:"RscInstallArchive", mode: "replaceDocuments"";

AggregationOperation lookupOpertaion = new CustomProjectAggregationOperation(lookupquery);
AggregationOperation matchOperation = new CustomProjectAggregationOperation(matchquery);
AggregationOperation projectOperation = new CustomProjectAggregationOperation(projectquery);
AggregationOperation outOperation = new CustomProjectAggregationOperation(outquery);
Aggregation aggregation = Aggregation.newAggregation(lookupOpertaion, matchOperation,projectOperation);


Custom Aggregation



public class CustomProjectAggregationOperation implements AggregationOperation 

private String jsonOperation;

public CustomProjectAggregationOperation(String jsonOperation)
this.jsonOperation = jsonOperation;


@Override
public Document toDocument(AggregationOperationContext aggregationOperationContext)
return aggregationOperationContext.getMappedObject(Document.parse(jsonOperation));











share|improve this question

















This question already has an answer here:



  • Find MongoDB records where array field is not empty

    10 answers



  • how to search the array with no empty value from mongodb in java?

    1 answer



  • Java return an empty list

    5 answers



how to write the below mnonodb query in the matchoperation I have tried the options $exists but did not get the desired results hence raised it.
so the solution is definitely different to the links referred to mark it as duplicate.



db.rsc_installtion_status.aggregate([
$lookup :

from:"vmdetails",
localField:"hostname",
foreignField:"hostname" ,
as:"rscinstall"

,

$match: "rscinstall": $eq: []

])


so far the code which i have is



LookupOperation lookupOperation = LookupOperation.newLookup().from("vmdetails").localField("hostname").foreignField("hostname").as("rscInstall");


i am not able to put the match criteria



 MatchOperation matchOperation = Aggregation.match(Criteria.where("rscinstall").equals(null));


Updated Answer -- I have tried the options which



 String lookupquery = "$lookup :from:"vmdetails",localField:"hostname",foreignField:"hostname"as:"rscinstall"";
String matchquery = " $match: "rscinstall": $eq: [] ";
String projectquery = "$project:"rscinstall":0";
String outquery = "$out:to:"RscInstallArchive", mode: "replaceDocuments"";

AggregationOperation lookupOpertaion = new CustomProjectAggregationOperation(lookupquery);
AggregationOperation matchOperation = new CustomProjectAggregationOperation(matchquery);
AggregationOperation projectOperation = new CustomProjectAggregationOperation(projectquery);
AggregationOperation outOperation = new CustomProjectAggregationOperation(outquery);
Aggregation aggregation = Aggregation.newAggregation(lookupOpertaion, matchOperation,projectOperation);


Custom Aggregation



public class CustomProjectAggregationOperation implements AggregationOperation 

private String jsonOperation;

public CustomProjectAggregationOperation(String jsonOperation)
this.jsonOperation = jsonOperation;


@Override
public Document toDocument(AggregationOperationContext aggregationOperationContext)
return aggregationOperationContext.getMappedObject(Document.parse(jsonOperation));






This question already has an answer here:



  • Find MongoDB records where array field is not empty

    10 answers



  • how to search the array with no empty value from mongodb in java?

    1 answer



  • Java return an empty list

    5 answers







spring-boot mongodb-query spring-data mongotemplate






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 13:17







Abrar Ahamed

















asked Mar 22 at 4:30









Abrar AhamedAbrar Ahamed

628




628




marked as duplicate by Neil Lunn mongodb-query
Users with the  mongodb-query badge can single-handedly close mongodb-query questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 22 at 6:16


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Neil Lunn mongodb-query
Users with the  mongodb-query badge can single-handedly close mongodb-query questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 22 at 6:16


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • Basically anything can always be represented with Document or BasicDBObject depending on the sping-mongo version used and it's underlying Java driver implementation. Probably the most simple and direct would be .ne(Collections.EMPTY_LIST) or ANY actual constructor of an "empty list". It's usually very acceptable to look for NOT fieldname.0 ( i.e $exists with false ) where 0 is the index position of the first array element. As long as you are certain you do not store an object with keys of 0 instead of an array, it's probably the more performant and flexible option

    – Neil Lunn
    Mar 22 at 6:23











  • @NeilLunn I have used the options which u mentioned but those didn't work. the questions may be similar but the solution is different .

    – Abrar Ahamed
    Mar 22 at 13:18

















  • Basically anything can always be represented with Document or BasicDBObject depending on the sping-mongo version used and it's underlying Java driver implementation. Probably the most simple and direct would be .ne(Collections.EMPTY_LIST) or ANY actual constructor of an "empty list". It's usually very acceptable to look for NOT fieldname.0 ( i.e $exists with false ) where 0 is the index position of the first array element. As long as you are certain you do not store an object with keys of 0 instead of an array, it's probably the more performant and flexible option

    – Neil Lunn
    Mar 22 at 6:23











  • @NeilLunn I have used the options which u mentioned but those didn't work. the questions may be similar but the solution is different .

    – Abrar Ahamed
    Mar 22 at 13:18
















Basically anything can always be represented with Document or BasicDBObject depending on the sping-mongo version used and it's underlying Java driver implementation. Probably the most simple and direct would be .ne(Collections.EMPTY_LIST) or ANY actual constructor of an "empty list". It's usually very acceptable to look for NOT fieldname.0 ( i.e $exists with false ) where 0 is the index position of the first array element. As long as you are certain you do not store an object with keys of 0 instead of an array, it's probably the more performant and flexible option

– Neil Lunn
Mar 22 at 6:23





Basically anything can always be represented with Document or BasicDBObject depending on the sping-mongo version used and it's underlying Java driver implementation. Probably the most simple and direct would be .ne(Collections.EMPTY_LIST) or ANY actual constructor of an "empty list". It's usually very acceptable to look for NOT fieldname.0 ( i.e $exists with false ) where 0 is the index position of the first array element. As long as you are certain you do not store an object with keys of 0 instead of an array, it's probably the more performant and flexible option

– Neil Lunn
Mar 22 at 6:23













@NeilLunn I have used the options which u mentioned but those didn't work. the questions may be similar but the solution is different .

– Abrar Ahamed
Mar 22 at 13:18





@NeilLunn I have used the options which u mentioned but those didn't work. the questions may be similar but the solution is different .

– Abrar Ahamed
Mar 22 at 13:18












0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?