« blib/lib/KinoSearch1/Index/TermInfosReader.pm
↑ Summary
blib/lib/KinoSearch1/Search/BooleanClause.pm »
| 1 | package KinoSearch1::Search::Query; | ||||||||||
| 2 | 18 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 18 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 18 | ▶ | use KinoSearch1::Util::ToolSet; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 18 | ▶ | use base qw( KinoSearch1::Util::Class ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 18 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 18 | __PACKAGE__->init_instance_vars( | |||||||||
| 9 | # constructor params / members | ||||||||||
| 10 | boost => 1, | ||||||||||
| 11 | ); | ||||||||||
| 12 | 18 | __PACKAGE__->ready_get_set(qw( boost )); | |||||||||
| 13 | } | ||||||||||
| 14 | |||||||||||
| 15 | =begin comment | ||||||||||
| 16 | |||||||||||
| 17 | my $string = $query->to_string( $field_name ); | ||||||||||
| 18 | |||||||||||
| 19 | Return a string representation of the query. $field_name is a default field, | ||||||||||
| 20 | and affects how the string is generated -- for instance, if a TermQuery's | ||||||||||
| 21 | field matches $field_name, the field will be omitted, while if it doesn't | ||||||||||
| 22 | match, the field will be included in the string. | ||||||||||
| 23 | |||||||||||
| 24 | =end comment | ||||||||||
| 25 | =cut | ||||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | sub to_string { shift->abstract_death } | ||||||||
|
Subroutine
to_string: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 28 | |||||||||||
| 29 | =begin comment | ||||||||||
| 30 | |||||||||||
| 31 | my $weight = $query->create_weight($searcher); | ||||||||||
| 32 | |||||||||||
| 33 | Only low-level Queries which rewrite themselves implement this method. | ||||||||||
| 34 | |||||||||||
| 35 | =end comment | ||||||||||
| 36 | =cut | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub create_weight { shift->abstract_death } | ||||||||
|
Subroutine
create_weight: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 39 | |||||||||||
| 40 | # Derive a weight for a high-level query. | ||||||||||
| 41 | 281 | ▶ | sub to_weight { # in Lucene, this method is simply "weight" | ||||||||
|
Subroutine
to_weight: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 42 | 281 | my ( $self, $searcher ) = @_; | |||||||||
| 43 | 281 | my $rewritten_self = $searcher->rewrite($self); | |||||||||
| 44 | 281 | my $weight = $rewritten_self->create_weight($searcher); | |||||||||
| 45 | 281 | my $sum = $weight->sum_of_squared_weights; | |||||||||
| 46 | 281 | my $sim = $self->get_similarity($searcher); | |||||||||
| 47 | 281 | my $norm = $sim->query_norm($sum); | |||||||||
| 48 | 281 | $weight->normalize($norm); | |||||||||
| 49 | 281 | return $weight; | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | =begin comment | ||||||||||
| 53 | |||||||||||
| 54 | my $rewritten_query = $query->rewrite( $index_reader ); | ||||||||||
| 55 | |||||||||||
| 56 | Called by high-level Queries that wish to reformulate themselves as | ||||||||||
| 57 | agglomerations of low-level queries. | ||||||||||
| 58 | |||||||||||
| 59 | =end comment | ||||||||||
| 60 | =cut | ||||||||||
| 61 | |||||||||||
| 62 | 277 | ▶ | sub rewrite { return shift } | ||||||||
|
Subroutine
rewrite: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 63 | |||||||||||
| 64 | =begin comment | ||||||||||
| 65 | |||||||||||
| 66 | my @terms = $query->extract_terms; | ||||||||||
| 67 | |||||||||||
| 68 | Return all the Terms within this query. | ||||||||||
| 69 | |||||||||||
| 70 | =end comment | ||||||||||
| 71 | =cut | ||||||||||
| 72 | |||||||||||
| 73 | 0 | ▶ | sub extract_terms { shift->abstract_death } | ||||||||
|
Subroutine
extract_terms: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 74 | |||||||||||
| 75 | # These will be needed by MultiSearcher if we add queries which rewrite | ||||||||||
| 76 | # themselves. | ||||||||||
| 77 | 0 | ▶ | sub combine { shift->todo_death } | ||||||||
|
Subroutine
combine: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 78 | 0 | ▶ | sub merge_boolean_queries { shift->todo_death } | ||||||||
|
Subroutine
merge_boolean_queries: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 79 | |||||||||||
| 80 | # return the Similarity implementation used by the Query. | ||||||||||
| 81 | 93 | ▶ | sub get_similarity { | ||||||||
|
Subroutine
get_similarity: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||
| 82 | 93 | my ( $self, $searcher, $field_name ) = @_; | |||||||||
| 83 | # This can be overriden in subclasses, allowing alternative Sims. | ||||||||||
| 84 | 93 | ▶ | return defined $field_name | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | ? $searcher->get_similarity($field_name) | ||||||||||
| 86 | : $searcher->get_similarity; | ||||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | 0 | ▶ | sub clone { shift->todo_death } | ||||||||
|
Subroutine
clone: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 90 | |||||||||||
| 91 | 18 | 1; | |||||||||
| 92 | |||||||||||
| 93 | __END__ | ||||||||||