|
Lines 50-55
use C4::Context;
Link Here
|
| 50 |
use Koha::Exceptions; |
50 |
use Koha::Exceptions; |
| 51 |
use Koha::Caches; |
51 |
use Koha::Caches; |
| 52 |
|
52 |
|
|
|
53 |
our %index_field_convert = ( |
| 54 |
'kw' => '', |
| 55 |
'ab' => 'abstract', |
| 56 |
'au' => 'author', |
| 57 |
'lcn' => 'local-classification', |
| 58 |
'callnum' => 'local-classification', |
| 59 |
'record-type' => 'rtype', |
| 60 |
'mc-rtype' => 'rtype', |
| 61 |
'mus' => 'rtype', |
| 62 |
'lc-card' => 'lc-card-number', |
| 63 |
'sn' => 'local-number', |
| 64 |
'biblionumber' => 'local-number', |
| 65 |
'yr' => 'date-of-publication', |
| 66 |
'pubdate' => 'date-of-publication', |
| 67 |
'acqdate' => 'date-of-acquisition', |
| 68 |
'date/time-last-modified' => 'date-time-last-modified', |
| 69 |
'dtlm' => 'date-time-last-modified', |
| 70 |
'diss' => 'dissertation-information', |
| 71 |
'nb' => 'isbn', |
| 72 |
'ns' => 'issn', |
| 73 |
'music-number' => 'identifier-publisher-for-music', |
| 74 |
'number-music-publisher' => 'identifier-publisher-for-music', |
| 75 |
'music' => 'identifier-publisher-for-music', |
| 76 |
'ident' => 'identifier-standard', |
| 77 |
'cpn' => 'corporate-name', |
| 78 |
'cfn' => 'conference-name', |
| 79 |
'pn' => 'personal-name', |
| 80 |
'pb' => 'publisher', |
| 81 |
'pv' => 'provider', |
| 82 |
'nt' => 'note', |
| 83 |
'notes' => 'note', |
| 84 |
'rcn' => 'record-control-number', |
| 85 |
'su' => 'subject', |
| 86 |
'su-to' => 'subject', |
| 87 |
#'su-geo' => 'subject', |
| 88 |
'su-ut' => 'subject', |
| 89 |
'ti' => 'title', |
| 90 |
'se' => 'title-series', |
| 91 |
'ut' => 'title-uniform', |
| 92 |
'an' => 'koha-auth-number', |
| 93 |
'authority-number' => 'koha-auth-number', |
| 94 |
'at' => 'authtype', |
| 95 |
'he' => 'heading', |
| 96 |
'rank' => 'relevance', |
| 97 |
'phr' => 'st-phrase', |
| 98 |
'wrdl' => 'st-word-list', |
| 99 |
'rt' => 'right-truncation', |
| 100 |
'rtrn' => 'right-truncation', |
| 101 |
'ltrn' => 'left-truncation', |
| 102 |
'rltrn' => 'left-and-right', |
| 103 |
'mc-itemtype' => 'itemtype', |
| 104 |
'mc-ccode' => 'ccode', |
| 105 |
'branch' => 'homebranch', |
| 106 |
'mc-loc' => 'location', |
| 107 |
'loc' => 'location', |
| 108 |
'stocknumber' => 'number-local-acquisition', |
| 109 |
'inv' => 'number-local-acquisition', |
| 110 |
'bc' => 'barcode', |
| 111 |
'mc-itype' => 'itype', |
| 112 |
'aub' => 'author-personal-bibliography', |
| 113 |
'auo' => 'author-in-order', |
| 114 |
'ff8-22' => 'ta', |
| 115 |
'aud' => 'ta', |
| 116 |
'audience' => 'ta', |
| 117 |
'frequency-code' => 'ff8-18', |
| 118 |
'illustration-code' => 'ff8-18-21', |
| 119 |
'regularity-code' => 'ff8-19', |
| 120 |
'type-of-serial' => 'ff8-21', |
| 121 |
'format' => 'ff8-23', |
| 122 |
'conference-code' => 'ff8-29', |
| 123 |
'festschrift-indicator' => 'ff8-30', |
| 124 |
'index-indicator' => 'ff8-31', |
| 125 |
'fiction' => 'lf', |
| 126 |
'fic' => 'lf', |
| 127 |
'literature-code' => 'lf', |
| 128 |
'biography' => 'bio', |
| 129 |
'ff8-34' => 'bio', |
| 130 |
'biography-code' => 'bio', |
| 131 |
'l-format' => 'ff7-01-02', |
| 132 |
'lex' => 'lexile-number', |
| 133 |
'hi' => 'host-item-number', |
| 134 |
'itu' => 'index-term-uncontrolled', |
| 135 |
'itg' => 'index-term-genre', |
| 136 |
); |
| 137 |
my $field_name_pattern = '[\w\-]+'; |
| 138 |
my $multi_field_pattern = "(?:\\.$field_name_pattern)*"; |
| 139 |
|
| 140 |
=head2 get_index_field_convert |
| 141 |
|
| 142 |
my @index_params = Koha::SearchEngine::Elasticsearch::QueryBuilder->get_index_field_convert(); |
| 143 |
|
| 144 |
Converts zebra-style search index notation into elasticsearch-style. |
| 145 |
|
| 146 |
C<@indexes> is an array of index names, as presented to L<build_query_compat>, |
| 147 |
and it returns something that can be sent to L<build_query>. |
| 148 |
|
| 149 |
B<TODO>: this will pull from the elasticsearch mappings table to figure out |
| 150 |
types. |
| 151 |
|
| 152 |
=cut |
| 153 |
|
| 154 |
sub get_index_field_convert() { |
| 155 |
return \%index_field_convert; |
| 156 |
} |
| 157 |
|
| 53 |
=head2 build_query |
158 |
=head2 build_query |
| 54 |
|
159 |
|
| 55 |
my $simple_query = $builder->build_query("hello", %options) |
160 |
my $simple_query = $builder->build_query("hello", %options) |
|
Lines 607-713
sub _convert_sort_fields {
Link Here
|
| 607 |
} @sort_by; |
712 |
} @sort_by; |
| 608 |
} |
713 |
} |
| 609 |
|
714 |
|
| 610 |
=head2 _convert_index_fields |
|
|
| 611 |
|
| 612 |
my @index_params = $self->_convert_index_fields(@indexes); |
| 613 |
|
| 614 |
Converts zebra-style search index notation into elasticsearch-style. |
| 615 |
|
| 616 |
C<@indexes> is an array of index names, as presented to L<build_query_compat>, |
| 617 |
and it returns something that can be sent to L<build_query>. |
| 618 |
|
| 619 |
B<TODO>: this will pull from the elasticsearch mappings table to figure out |
| 620 |
types. |
| 621 |
|
| 622 |
=cut |
| 623 |
|
| 624 |
our %index_field_convert = ( |
| 625 |
'kw' => '', |
| 626 |
'ab' => 'abstract', |
| 627 |
'au' => 'author', |
| 628 |
'lcn' => 'local-classification', |
| 629 |
'callnum' => 'local-classification', |
| 630 |
'record-type' => 'rtype', |
| 631 |
'mc-rtype' => 'rtype', |
| 632 |
'mus' => 'rtype', |
| 633 |
'lc-card' => 'lc-card-number', |
| 634 |
'sn' => 'local-number', |
| 635 |
'biblionumber' => 'local-number', |
| 636 |
'yr' => 'date-of-publication', |
| 637 |
'pubdate' => 'date-of-publication', |
| 638 |
'acqdate' => 'date-of-acquisition', |
| 639 |
'date/time-last-modified' => 'date-time-last-modified', |
| 640 |
'dtlm' => 'date-time-last-modified', |
| 641 |
'diss' => 'dissertation-information', |
| 642 |
'nb' => 'isbn', |
| 643 |
'ns' => 'issn', |
| 644 |
'music-number' => 'identifier-publisher-for-music', |
| 645 |
'number-music-publisher' => 'identifier-publisher-for-music', |
| 646 |
'music' => 'identifier-publisher-for-music', |
| 647 |
'ident' => 'identifier-standard', |
| 648 |
'cpn' => 'corporate-name', |
| 649 |
'cfn' => 'conference-name', |
| 650 |
'pn' => 'personal-name', |
| 651 |
'pb' => 'publisher', |
| 652 |
'pv' => 'provider', |
| 653 |
'nt' => 'note', |
| 654 |
'notes' => 'note', |
| 655 |
'rcn' => 'record-control-number', |
| 656 |
'su' => 'subject', |
| 657 |
'su-to' => 'subject', |
| 658 |
#'su-geo' => 'subject', |
| 659 |
'su-ut' => 'subject', |
| 660 |
'ti' => 'title', |
| 661 |
'se' => 'title-series', |
| 662 |
'ut' => 'title-uniform', |
| 663 |
'an' => 'koha-auth-number', |
| 664 |
'authority-number' => 'koha-auth-number', |
| 665 |
'at' => 'authtype', |
| 666 |
'he' => 'heading', |
| 667 |
'rank' => 'relevance', |
| 668 |
'phr' => 'st-phrase', |
| 669 |
'wrdl' => 'st-word-list', |
| 670 |
'rt' => 'right-truncation', |
| 671 |
'rtrn' => 'right-truncation', |
| 672 |
'ltrn' => 'left-truncation', |
| 673 |
'rltrn' => 'left-and-right', |
| 674 |
'mc-itemtype' => 'itemtype', |
| 675 |
'mc-ccode' => 'ccode', |
| 676 |
'branch' => 'homebranch', |
| 677 |
'mc-loc' => 'location', |
| 678 |
'loc' => 'location', |
| 679 |
'stocknumber' => 'number-local-acquisition', |
| 680 |
'inv' => 'number-local-acquisition', |
| 681 |
'bc' => 'barcode', |
| 682 |
'mc-itype' => 'itype', |
| 683 |
'aub' => 'author-personal-bibliography', |
| 684 |
'auo' => 'author-in-order', |
| 685 |
'ff8-22' => 'ta', |
| 686 |
'aud' => 'ta', |
| 687 |
'audience' => 'ta', |
| 688 |
'frequency-code' => 'ff8-18', |
| 689 |
'illustration-code' => 'ff8-18-21', |
| 690 |
'regularity-code' => 'ff8-19', |
| 691 |
'type-of-serial' => 'ff8-21', |
| 692 |
'format' => 'ff8-23', |
| 693 |
'conference-code' => 'ff8-29', |
| 694 |
'festschrift-indicator' => 'ff8-30', |
| 695 |
'index-indicator' => 'ff8-31', |
| 696 |
'fiction' => 'lf', |
| 697 |
'fic' => 'lf', |
| 698 |
'literature-code' => 'lf', |
| 699 |
'biography' => 'bio', |
| 700 |
'ff8-34' => 'bio', |
| 701 |
'biography-code' => 'bio', |
| 702 |
'l-format' => 'ff7-01-02', |
| 703 |
'lex' => 'lexile-number', |
| 704 |
'hi' => 'host-item-number', |
| 705 |
'itu' => 'index-term-uncontrolled', |
| 706 |
'itg' => 'index-term-genre', |
| 707 |
); |
| 708 |
my $field_name_pattern = '[\w\-]+'; |
| 709 |
my $multi_field_pattern = "(?:\\.$field_name_pattern)*"; |
| 710 |
|
| 711 |
sub _convert_index_fields { |
715 |
sub _convert_index_fields { |
| 712 |
my ( $self, @indexes ) = @_; |
716 |
my ( $self, @indexes ) = @_; |
| 713 |
|
717 |
|