Bugzilla – Attachment 30318 Details for
Bug 9368
specific behavior of yr and acqdate indexes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9368 [ALTERNATE] - specific behavior of yr and acqdate indexes
Bug-9368-ALTERNATE---specific-behavior-of-yr-and-a.patch (text/plain), 5.76 KB, created by
Fridolin Somers
on 2014-07-30 09:18:57 UTC
(
hide
)
Description:
Bug 9368 [ALTERNATE] - specific behavior of yr and acqdate indexes
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2014-07-30 09:18:57 UTC
Size:
5.76 KB
patch
obsolete
>From 87a1eed9e756d4d344f637a55229b408f49f4776 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Wed, 18 Jun 2014 13:45:31 +1000 >Subject: [PATCH] Bug 9368 [ALTERNATE] - specific behavior of yr and acqdate > indexes > >This patch fixes the "Publication date" and "Acquisition date" >searches when using non-QueryParser and QueryParser searches. > >It adds structure attributes to the template, which is consistent >with how phrase searching is currently handled. > >It removes unnecessary code from Search.pm, adds some necessary >code which is consistent with existing code, and adds a lot of >explanatory comments. > >_TEST PLAN_ > >Before applying: >0) Turn off QueryParser >1) Try a "Publication date" or "Acquisition date" search from the >staff client advanced search. >2) Note that even though the description on the result page makes >it seem like you're doing an index-specific search, you're actually >doing a keyword search. You can verify this by checking the 008 >from positions 7 to 10 for "Publication date" or "Date accessioned" >on items for "Acquisition date". > >3) Turn on QueryParser >4) Try doing the searches from Step 1. >5) A "Publication date" search should probably produce zero results > >After applying patch: >6) Keep QueryParser on >7) Try doing the searches from Step 1. >8) Notice that you're actually getting results consistent with >your search (ie the 008/7-10 shows the date you searched for, >and there is a "Date accessioned" in items which matches your >search) > >9) Turn off QueryParser >10) Note that your results are exactly the same as step 8 >(N.B. this is because QueryParser is falling back to non-QP mode >instead of producing a bad query.) > >Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> >--- > C4/Search.pm | 27 +++++++++++++++++----- > .../prog/en/includes/search_indexes.inc | 13 +++++++++-- > 2 files changed, 32 insertions(+), 8 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 219de1e..ae7b850 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -1371,17 +1371,28 @@ sub buildQuery { > my $index = $indexes[$i]; > > # Add index-specific attributes >+ >+ #Afaik, this 'yr' condition will only ever be met in the staff client advanced search >+ #for "Publication date", since typing 'yr:YYYY' into the search box produces a CCL query, >+ #which is processed higher up in this sub. Other than that, year searches are typically >+ #handled as limits which are not processed her either. >+ > # Date of Publication >- if ( $index eq 'yr' ) { >- $index .= ",st-numeric"; >- $indexes_set++; >+ if ( $index =~ /yr/ ) { >+ #weight_fields/relevance search causes errors with date ranges >+ #In the case of YYYY-, it will only return records with a 'yr' of YYYY (not the range) >+ #In the case of YYYY-YYYY, it will return no results > $stemming = $auto_truncation = $weight_fields = $fuzzy_enabled = $remove_stopwords = 0; > } > > # Date of Acquisition >- elsif ( $index eq 'acqdate' ) { >- $index .= ",st-date-normalized"; >- $indexes_set++; >+ elsif ( $index =~ /acqdate/ ) { >+ #stemming and auto_truncation would have zero impact since it already is YYYY-MM-DD format >+ #Weight_fields probably SHOULD be turned OFF, otherwise you'll get records floating to the >+ #top of the results just because they have lots of item records matching that date. >+ #Fuzzy actually only applies during _build_weighted_query, and is reset there anyway, so >+ #irrelevant here >+ #remove_stopwords doesn't function anymore so is irrelevant > $stemming = $auto_truncation = $weight_fields = $fuzzy_enabled = $remove_stopwords = 0; > } > # ISBN,ISSN,Standard Number, don't need special treatment >@@ -1568,9 +1579,13 @@ sub buildQuery { > # This is flawed , means we can't search anything with : in it > # if user wants to do ccl or cql, start the query with that > # $query =~ s/:/=/g; >+ #NOTE: We use several several different regexps here as you can't have variable length lookback assertions > $query =~ s/(?<=(ti|au|pb|su|an|kw|mc|nb|ns)):/=/g; > $query =~ s/(?<=(wrdl)):/=/g; > $query =~ s/(?<=(trn|phr)):/=/g; >+ $query =~ s/(?<=(st-numeric)):/=/g; >+ $query =~ s/(?<=(st-year)):/=/g; >+ $query =~ s/(?<=(st-date-normalized)):/=/g; > $limit =~ s/:/=/g; > for ( $query, $query_desc, $limit, $limit_desc ) { > s/ +/ /g; # remove extra spaces >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc >index 67725c6..2492ec6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc >@@ -40,6 +40,15 @@ > [% END %] > <option value="pb">Publisher</option> > <option value="pl">Publisher location</option> >- <option value="yr">Publication date (yyyy)</option> >- <option value="acqdate">Acquisition date (yyyy-mm-dd)</option> >+ [%# >+ Use non-normalized st-year instead of st-numeric, >+ since pubdate can include 'u' to signify unkown >+ dates. See "Legal Characters" at: >+ http://www.loc.gov/marc/bibliographic/bd008a.html >+ >+ This search is also for date ranges due to the >+ special Zebra r=r CCL mapping for 'yr' >+ %] >+ <option value="yr,st-year">Publication date (yyyy-yyyy)</option> >+ <option value="acqdate,st-date-normalized">Acquisition date (yyyy-mm-dd)</option> > </select> >-- >1.9.1
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 9368
:
14472
|
15114
|
16268
|
26652
|
28916
|
30318
|
31552