Bugzilla – Attachment 56868 Details for
Bug 17500
Use Elasticsearch to search for patrons
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17500: Add a script to reindex patrons
Bug-17500-Add-a-script-to-reindex-patrons.patch (text/plain), 2.30 KB, created by
Jonathan Druart
on 2016-10-26 13:23:07 UTC
(
hide
)
Description:
Bug 17500: Add a script to reindex patrons
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-10-26 13:23:07 UTC
Size:
2.30 KB
patch
obsolete
>From 6fe174d0676bb110de4fa4ad1c8d71ba0a277a78 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 26 Oct 2016 12:33:49 +0200 >Subject: [PATCH] Bug 17500: Add a script to reindex patrons > >--- > misc/search_tools/reindex_patrons.pl | 60 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 60 insertions(+) > create mode 100644 misc/search_tools/reindex_patrons.pl > >diff --git a/misc/search_tools/reindex_patrons.pl b/misc/search_tools/reindex_patrons.pl >new file mode 100644 >index 0000000..ed581b7 >--- /dev/null >+++ b/misc/search_tools/reindex_patrons.pl >@@ -0,0 +1,60 @@ >+use Modern::Perl; >+ >+use Koha::Patrons; >+use Koha::SearchEngine::Elasticsearch; >+ >+use Koha::SearchEngine::Elasticsearch::Indexer; >+ >+my $index_name = "patrons"; >+my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new( { index => $index_name } ); >+ >+$indexer->drop_index; >+ >+my $patrons = Koha::Patrons->search; >+ >+my ( @id_buffer, @commit_buffer ); >+while ( my $patron = $patrons->next ) { >+ my $id = $patron->borrowernumber; >+ my $record = $patron->unblessed; >+ $record->{_id} = $id; >+ push @id_buffer, $id; >+ push @commit_buffer, $record; >+} >+ >+warn "committing"; >+ >+if ( !$indexer->store ) { >+ >+ my $params = $indexer->get_elasticsearch_params(); >+ my $mappings = { >+ data => { >+ properties => { >+ borrowernumber => { >+ type => 'string', >+ search_analyzer => 'analyser_standard', >+ index_analyzer => 'analyser_standard', >+ }, >+ cardnumber => { >+ type => 'string', >+ search_analyzer => 'analyser_standard', >+ index_analyzer => 'analyser_standard', >+ }, >+ surname => { >+ type => 'string', >+ search_analyzer => 'analyser_standard', >+ index_analyzer => 'analyser_standard', >+ }, >+ } >+ } >+ }; >+ $indexer->store( >+ Catmandu::Store::ElasticSearch->new( >+ %$params, >+ index_settings => $indexer->get_elasticsearch_settings(), >+ index_mappings => $mappings, >+ ) >+ ); >+} >+ >+$indexer->store->bag->add_many(\@commit_buffer); >+$indexer->store->bag->commit; >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17500
:
56867
|
56868
|
56869
|
56870
|
56871
|
56872
|
61481
|
61482
|
61483
|
61484
|
61485
|
61486
|
61487