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

196
Views
¿Se puede usar la búsqueda de texto completo de MongoDB con Spring Data REST?

Empecé a jugar con Spring Data Rest y quería exponer un buscador para un campo que es texto indexado en MongoDB. Tengo la siguiente definición de índice:

 @TextIndexed private String title;

y verificó que se crea el índice. He creado un método de búsqueda en la definición del repositorio:

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

Llamando a la URL de la API REST:

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

Obtuve el siguiente error:

 2017-01-19 13:16:41.831 ERROR 16705 --- [nio-8080-exec-9] oaccC[.[.[/].[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] ....

¿Cuál sería la forma correcta de llamar a la API REST? No puedo encontrar ninguna documentación al respecto. ¿O cómo sería posible escribir un convertidor para TextCriteria?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Después de un tiempo volví a esto y encontré la respuesta definiendo un buscador con una notación @Query:

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

0

No está relacionado con mongo, pero Spring Rest le dice que no puede convertir la cadena entrante (de su solicitud web) en un parámetro de método expuesto. Tiene 2 opciones: crear y registrar el convertidor o el método de ajuste en cuestión y convertir las cadenas a los tipos requeridos usted mismo

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!