2

I have created Basic search application in Vespa with an implementation of the Searcher class. I have fed these below documents using my application one by one.

{
    "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
    }
}

My Searcher class is below:

public class ExampleSearcher extends Searcher {

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

        retrun execution.search(query); 
    }
}

Now when I search using the API:

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

I got the result:

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

But I should get this result output:

{
    "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
            }
        }]
    }
}

What am I doing wrong or how should I do it?

dkurzaj
  • 346
  • 4
  • 13
Mohammad Sunny
  • 371
  • 1
  • 3
  • 15

1 Answers1

2

To actually search the content node(s) instead of just mocking a Hello world result as in the example you'll need to add to your chain 'inherits=vespa' to the search chain configuration in services.xml.

Jo Kristian Bergum
  • 2,984
  • 5
  • 8