jina.drivers.rank.aggregate

class jina.drivers.rank.aggregate.BaseAggregateMatchesRanker(keep_source_matches_as_chunks=False, *args, **kwargs)[source]

Bases: jina.drivers.rank.BaseRankDriver

Drivers inherited from this Driver will focus on aggregating scores from chunks to its parents.

Parameters

keep_old_matches_as_chunks – A flag to indicate if the driver must return the old matches of the query or its chunks

(at a greater granularity level (k + 1)) as the chunks of the new computed matches (at granularity level k).

Useful to keep track of the chunks that lead to a retrieved result.

Note

  • The chunks of the matches will only contain the chunks that lead to the document matching, not all the chunks of the match.

class QueryMatchInfo(match_parent_id, match_id, query_id, score)

Bases: tuple

Create new instance of QueryMatchInfo(match_parent_id, match_id, query_id, score)

property match_id

Alias for field number 1

property match_parent_id

Alias for field number 0

property query_id

Alias for field number 2

property score

Alias for field number 3

class jina.drivers.rank.aggregate.Chunk2DocRankDriver(traversal_paths=('c', ), *args, **kwargs)[source]

Bases: jina.drivers.rank.aggregate.BaseAggregateMatchesRanker

Extract matches score from chunks and use the executor to compute the rank and assign the resulting matches to the level above.

Input-Output ::

Input: document: {granularity: k-1}

|- chunks: {granularity: k} | |- matches: {granularity: k} | |- chunks: {granularity: k}

|- matches: {granularity: k}

Output: document: {granularity: k-1}

|- chunks: {granularity: k} | |- matches: {granularity: k} | |- chunks: {granularity: k} | |- matches: {granularity: k} | |-matches: {granularity: k-1} (Ranked according to Ranker Executor)

Note

  • It traverses on chunks not on matches. This is because ranker needs context information

from matches for several chunks

Parameters

keep_old_matches_as_chunks – A flag to indicate if the driver must return the old matches of the query or its chunks

(at a greater granularity level (k + 1)) as the chunks of the new computed matches (at granularity level k).

Useful to keep track of the chunks that lead to a retrieved result.

Note

  • The chunks of the matches will only contain the chunks that lead to the document matching, not all the chunks of the match.

class jina.drivers.rank.aggregate.AggregateMatches2DocRankDriver(traversal_paths=('m', ), *args, **kwargs)[source]

Bases: jina.drivers.rank.aggregate.BaseAggregateMatchesRanker

This Driver is intended to take a document with matches at a given granularity > 0, clear those matches and substitute these matches by the documents at a lower granularity level. Input-Output

Input:
document: {granularity: k}
    |- matches: {granularity: k}
    
Output:
document: {granularity: k}
    |- matches: {granularity: k-1} (Sorted according to Ranker Executor)

Imagine a case where we are querying a system with text documents chunked by sentences. When we query the system, we use sentences (chunks) to query it. So at some point we will have: `query sentence (documents of granularity 1):

matches: indexed sentences (documents of level depth 1)`

` But in the output we want to have the full document that better matches the sentence. `query sentence (documents of granularity 1):

matches: indexed full documents (documents of granularity 0).

` Using this Driver before querying a Binary Index with full binary document data can be very useful to implement a search system.

Parameters

keep_old_matches_as_chunks – A flag to indicate if the driver must return the old matches of the query or its chunks

(at a greater granularity level (k + 1)) as the chunks of the new computed matches (at granularity level k).

Useful to keep track of the chunks that lead to a retrieved result.

Note

  • The chunks of the matches will only contain the chunks that lead to the document matching, not all the chunks of the match.