Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
Can MongoDBs full text search be used with Spring Data REST?

I just started playing around with Spring Data Rest and wanted to expose a finder for a field which is text indexed in MongoDB. I have the following index definition:

@TextIndexed
private String title;

and verified that the index is created. I have created a finder method on the repository definition:

public interface ContentRespository extends MongoRepository<Content, String> {
    public Page<Content> findByTitle(@Param("title") TextCriteria title, @Param("pageable") Pageable pageable);
}

By calling the REST API URL:

http://localhost:8080/contents/search/findByTitle?title=test

I get the following error:

2017-01-19 13:16:41.831 ERROR 16705 --- [nio-8080-exec-9] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.repository.support.QueryMethodParameterConversionException: Failed to convert test into org.springframework.data.mongodb.core.query.TextCriteria!] with root cause

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [@org.springframework.data.repository.query.Param  org.springframework.data.mongodb.core.query.TextCriteria]
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:324) ~[spring-core-4.3.4.RELEASE.jar:4.3.4.RELEASE]
....

What would be the correct way to call the REST API? I can't find any documentation about it. Or how would it be possible to write a converter for TextCriteria?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

After some time I came back to this and found the answer by defining a finder with a @Query notation:

@Query("{$text: {$search: ?0}}")
public Page<Content> findByTitle(@Param("title") String title, @Param("pageable") Pageable pageable);
over 4 years ago · Santiago Trujillo Report

0

Not related to mongo - but spring rest says you that it can not convert incoming string ( from you web request ) to exposed method parameter. You have 2 options - create and register converter or wrap method in question and convert strings to required types yourself

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!