spring数据mongodb全文搜索

spring数据mongodb全文搜索,spring,mongodb,spring-data-mongodb,Spring,Mongodb,Spring Data Mongodb,我有一个域名 @Document public @Data class Note { @Id private String noteId; private String owner; @TextIndexed private String name; @TextIndexed private String text; private List<Tag> tags; private LocalDate date;

我有一个域名

@Document
public @Data class Note {

    @Id
    private String noteId;
    private String owner;
    @TextIndexed
    private String name;
    @TextIndexed
    private String text;
    private List<Tag> tags;
    private LocalDate date;
我像这样传递信息

localhost:8080/notes-rest/search/custom?criteria={'name':'1234', 'text': 'trx'}
执行全文搜索的存储库方法如下所示

@GetMapping("/notes-rest/search/custom")
public List<Note> searchNotes(@RequestParam("criteria") String searchCriteria) {
    LOGGER.info("Attempt to perform full text search by criteria: [{}].", searchCriteria);
    return searchRepository.findNotesByCriteria(searchCriteria);
}
@Repository
public class SearchRepository implements ISearchRepository {

    @Autowired
    private MongoTemplate template;

    @Override
    public List<Note> findNotesByCriteria(String searchCriteria) {
        TextCriteria criteria = TextCriteria.forDefaultLanguage().matching(searchCriteria);
        Query query = TextQuery.queryText(criteria);
        return template.find(query, Note.class);
    }
}

问题出在哪里?

我将搜索条件的格式更改为
{name:“borl”,text:“t”}
,似乎它开始正常工作了

更改find调用以指定所需的fields@ScottStensland你什么意思?我在公共汽车上。。。Read您确定文本字段已正确编入索引并已使用吗?文本搜索采用搜索词而不是搜索条件。类似于
TextCriteria=TextCriteria.forDefaultLanguage().matching(“1234 trx”)
[
    {
        "noteId": "594eae353bc51592f432b62e",
        "owner": "xxx",
        "name": "xxx note",
        "text": "My text",
        "tags": [
            {
                "tagId": null,
                "tag": "basic2"
            }
        ],
        "date": [
            1997,
            12,
            15
        ]
    },
    {
        "noteId": "594ea38a3bc5150070d0aed2",
        "owner": "system",
        "name": "system note",
        "text": "My text",
        "tags": [
            {
                "tagId": "594e629b3bc5150f4c869905",
                "tag": "basic"
            }
        ],
        "date": [
            1997,
            12,
            15
        ]
    },
    {
        "noteId": "594ea0ae3bc5150ad88a1dfc",
        "owner": "borland",
        "name": "borland note",
        "text": "My text",
        "tags": null,
        "date": [
            1992,
            12,
            15
        ]
    }
]