I have a simple spring web application that uses mongodb. I have a requirement to search for the collection identifier by string, where the string should work with the regex expression. The method for creating my criteria is as follows.
public Criteria getSearchCriteriaQuery(String keyword, String colomnArray[]){
Criteria[] criteriaList = new Criteria[colomnArray.length];
for (int i=0; i<colomnArray.length; i++) {
criteriaList[i] = Criteria.where(colomnArray[i]).regex(keyword, "i");
}
return this.criteria.orOperator(criteriaList);
}
My domain is as follows
@Document
public class sampleDomain{
@Id
private String id;
....
}
When I use "id" / "_id" as the column name, it does not return anything, even if I send a valid row as a keyword. An example of the query I tried is below
id in db - 560299fe627942619bcfdc87
keyword - 560
Is there a solution for this? thanks in advance
source
share