我在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
}
}
我的搜索器类如下:
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
}
}]
}
}
我做错了什么或我应该怎么做?
要实际搜索内容节点,而不是像示例中那样仅仅模拟 Hello world 结果,您需要将"inherits=vespa"添加到服务中的搜索链配置中.xml。