kidpollo / tanker

IndexTank Integration with your fav ORM
MIT License
97 stars 30 forks source link

Feature request: access to `query_relevance_score` #64

Open hale opened 12 years ago

hale commented 12 years ago

I'd like to be able to only show results with a relevance above a certain threshhold.

Since we're doing some query expansion, the results set contains a lot of fuzz - documents which are only vaguely relevant. From reading the API docs it seems that the HTTP response body does include the relevance score of each result, which sounds perfect for this situation. However, as far as I can tell from the documentation Tanker doesn't support it.

Example

results = Article.search_tank('keyword')
top_results = results.select { |a| a.relevance >= 2 }

Relevant API Section

The response body will contain a JSON map with these fields:
    "matches": the total number of matches for the query
    "facets": a map from category name to a values count map
    "results": a list of objects with the "docid" field
        query_relevance_score: query specific document relevance score
        variable_<N>: variable value, from 0 to N
        category_<NAME>: category value for the NAME document category / facet
    "search_time": the time it took to search in seconds

Possible solutions

Let me know your thoughts, when I have some time I'd love to help work on this if you think it sounds sensible.

hale commented 12 years ago

Another solution for people who might also be in a similar situation:

Consider using both the IndexTank client gem and Tanker. I find the indexing features of Tanker most useful, so one option is to use Tanker for indexing and the IndexTank client gem for searching.

This is something that was suggested to me by Searchify.