A
A
ALTAIR952017-03-31 15:10:47
Java
ALTAIR95, 2017-03-31 15:10:47

How to do a fulltext search on a DbObject?

repository

@Query("{ $text : {$search : ?0}}")
    List<CvRecord> findLikeKeywords(String regexp);

    List<CvRecord> findAllBy(TextCriteria criteria);

Class for writing to the database
@TextIndexed private final static String DOC_ID_KEY = "doc_id";

    @Id
    private String id;

    @Indexed(name = "doc_id", unique = true)
    private String docId;

    @TextIndexed private BasicDBObject dbObject;

    @TextIndexed private String privet = "bla test";

I'm trying to search like this:
TextCriteria criteria = TextCriteria.forDefaultLanguage().matchingAny("test", "java", "сгу");
        List<CvRecord> result = repository.findAllBy(criteria);
        List<CvRecord> result1 =  repository.findLikeKeywords("test");

Successfully searches by class fields, but I need search by data from dbObject. How can I do it? Is it possible? maybe another annotation is needed?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question