Skip to content

Feature request: access to query_relevance_score #64

@hale

Description

@hale

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

  • Instead of returning an array of whichever model, return an array of Result which extends the model and adds a new field called relevance, which is fetched from the IndexTank response.
  • Just expose the raw JSON response when you call results.index_tank_json, as a fallback for situations where Tanker doesn't cover all the API's functionality.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions