Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

200
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda