2

我在 Vespa 中使用 Searcher 类的实现创建了基本搜索应用程序。我已经使用我的应用程序一一提供了以下这些文件。

{
    "fields": {
        "album": "Good",
        "artist": "Arijit",
        "title": "tum ho",
        "year": 2017,
        "duration": 300
    }
}
{
    "fields": {
        "album": "Good",
        "artist": "Atif",
        "title": "bewajah",
        "year": 2017,
        "duration": 300
    }
}
{
    "fields": {
        "album": "bad",
        "artist": "Neha",
        "title": "tere",
        "year": 2017,
        "duration": 400
    }
}

我的 Searcher 类如下:

public class ExampleSearcher extends Searcher {

    @Override
    public Result search(Query query, Execution execution) {

        retrun execution.search(query); 
    }
}

现在,当我使用 API 进行搜索时:

http://localhost:8080/search/?album=good OR http://localhost:8080/search/?=good

我得到了结果:

{
    "root": {
        "id": "toplevel",
        "relevance": 1,
        "fields": {
            "totalCount": 0
        }
    }
}

但我应该得到这个结果输出:

{
    "root": {
        "id": "toplevel",
        "relevance": 1,
        "fields": {
            "totalCount": 2
        },
        "children": [{
            "id": "good",
            "relevance": 1,
            "fields": {
                "album": "Good",
                "artist": "Arijit",
                "title": "tum ho",
                "year": 2017,
                "duration": 300
            }
        }, {
            "id": "good",
            "relevance": 1,
            "fields": {
                "album": "Good",
                "artist": "Atif",
                "title": "bewajah",
                "year": 2017,
                "duration": 300
            }
        }]
    }
}

我做错了什么或者我应该怎么做?

4

1 回答 1

2

要实际搜索内容节点,而不是像示例中那样仅仅模拟 Hello world 结果,您需要将链“inherits=vespa”添加到 services.xml 中的搜索链配置中。

于 2018-08-28T10:59:51.573 回答