Reputation: 5733
I have an Entity class in my application using spring data and mongoDB which looks like this:
@Document(collection = "DocumentFile")
public class DocumentFile {
private String originalFileName;
and now I want to create a search method for the field originalFileName. The name of originalFileName e.g. can look like this:
testFileName-2016-USA.pdf
I will search e.g. for FileName AND 2016 and the file mentioned above should be match. My question now would be how I can do this. I would need a method like this:
public interface DocumentFileRepository extends MongoRepository<DocumentFile , String> {
List<DocumentFile> findDocumentFilesByOriginalFileNameContaining(final List<String> searchStrings);
}
Is there a possibility to do that like this?
Upvotes: 0
Views: 53
Reputation: 16106
You could use In
Keyword Query Method.
If you see the reference documentation the keyword In searches a column/pair key row/value stored.
Example in reference documentation:
In - findByAgeIn(Collection ages) - {"age" : {"$in" : [ages…]}}
So in your case you could do something like:
List<DocumentFile> findByOriginalFileNameIn(final Collection<String> searchStrings);
Upvotes: 0