searsia / searsiaserver

Federated Web Search Server
Apache License 2.0
8 stars 4 forks source link

Result 'undefined' #6

Closed WimVanDerZijden closed 6 years ago

WimVanDerZijden commented 8 years ago

I have a resource that always returns a result that matches the Item Xpath query, even when there are no results.

If there is a result, it will return something like this:

{"Title":"Frozen","Year":"2013","Rated":"PG","Released":"27 Nov 2013","Runtime":"102 min",...}

When there are no results, it returns:

{"Response":"False","Error":"Movie not found!"}

When this happens, this result will still show up in the search results, as 'undefined'.

The resource is:

{"hits":[{"tags":"#movie","url":"http://www.imdb.com/title/"}],"resource":{"id":"omdbapi","mimetype":"application/json","urltemplate":"http://www.omdbapi.com/?t={q}","extractors":{"tags":"'#movie'","title":"//Title","description":"//Plot","image":"//Poster","url":"concat('http://www.imdb.com/title/',//imdbID)"},"testquery":"Frozen","name":"OMDb API","itempath":".","apitemplate":"http://www.omdbapi.com/?t={q}"},"searsia":"v0.3.2"}

djoerd commented 8 years ago

Interesting case. If you try to add the engine with a query that does not give results (for instance 'frooozen'), you get the following:

Update failed. 405 Method Not Allowed. Search result without title for query: 'frooozen'

You might fix this by making the item_path: //Title (to make sure that the system only creates a search results if the Title element is there). But it's a bug nevertheless, the code currently assumes that a search result always has a title, but it should do something smart if it has none.

searsia commented 6 years ago

Version 1.0.3 gives an error message when testing a resource that returns a result that does not have a title nor a rid.