Bug 14031 - Make itemnumber a numeric search in ccl.properties
Summary: Make itemnumber a numeric search in ccl.properties
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: David Cook
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-21 00:33 UTC by David Cook
Modified: 2016-06-21 21:40 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 14031 - Itemnumber should be a numeric search in ccl.properties (1.40 KB, patch)
2015-04-21 00:42 UTC, David Cook
Details | Diff | Splinter Review
Bug 14031 - Itemnumber should be a numeric search in ccl.properties (1.61 KB, patch)
2015-06-05 09:03 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 14031 - Itemnumber should be a numeric search in ccl.properties (1.68 KB, patch)
2015-08-05 14:26 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2015-04-21 00:33:37 UTC
At the moment, if you do a search in the OPAC or staff client for "itemnumber:1", you'll get no results even when you have an item with an itemnumber of 1.

That's because Zebra defaults to a word list search, but there is no word index for itemnumber. It's a numeric index. So, to find that item, you'll have to try "itemnumber,st-numeric:1".

However, by tweaking ccl.properties, we can make "itemnumber:1" work as well. We already do this for "notforloan" which we know will always be numeric.

Current ccl.properties:

notforloan 1=8008 4=109
itemnumber 1=8010

4=109 is the PQF/RPN for "st-numeric".

So... let's just add "4=109" to itemnumber, and be merry!
Comment 1 David Cook 2015-04-21 00:42:30 UTC Comment hidden (obsolete)
Comment 2 Magnus Enger 2015-06-05 09:03:53 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2015-06-18 09:45:55 UTC
It does not work for UNIMARC, the itemnumber is not indexed.
Comment 4 Jonathan Druart 2015-06-18 09:46:25 UTC
Shouldn't we do the same for the biblionumber?
Comment 5 David Cook 2015-06-21 23:49:48 UTC
(In reply to Jonathan Druart from comment #3)
> It does not work for UNIMARC, the itemnumber is not indexed.

In that case, perhaps I should amend the name of the bug to be MARC21/NORMARC specific?

Do you want itemnumber to be indexed in UNIMARC?
Comment 6 David Cook 2015-06-21 23:51:14 UTC
(In reply to Jonathan Druart from comment #4)
> Shouldn't we do the same for the biblionumber?

"biblionumber" isn't indexed in MARC21, although the biblionumber is indexed as "local-number" in MARC21. It's indexed as "numeric" and "word" though, so I haven't encountered this problem with it before.

I suppose it might be worthwhile having a larger discussion about what indexes should exist and how we index them... (as numeric, word, phrase, etc)
Comment 7 Jonathan Druart 2015-06-22 11:14:28 UTC
(In reply to David Cook from comment #5)
> (In reply to Jonathan Druart from comment #3)
> > It does not work for UNIMARC, the itemnumber is not indexed.
> 
> In that case, perhaps I should amend the name of the bug to be
> MARC21/NORMARC specific?
> 
> Do you want itemnumber to be indexed in UNIMARC?

Ccing Fridolin as a Zebra and UNIMARC expert :)
Comment 8 Fridolin SOMERS 2015-06-24 14:49:48 UTC
(In reply to Jonathan Druart from comment #7)
> (In reply to David Cook from comment #5)
> > (In reply to Jonathan Druart from comment #3)
> > > It does not work for UNIMARC, the itemnumber is not indexed.
> > 
> > In that case, perhaps I should amend the name of the bug to be
> > MARC21/NORMARC specific?
> > 
> > Do you want itemnumber to be indexed in UNIMARC?
> 
> Ccing Fridolin as a Zebra and UNIMARC expert :)

No lib as never asked for it I think.
I'd say keep it not indexed.

Note that using numeric search is only useful when using comparisons greater or lower than.
Default search is phrase so indexing itemnumber subfield as phrase should be enough to allow searching : "itemnumber:9999"
Comment 9 David Cook 2015-07-06 02:36:06 UTC
(In reply to Fridolin SOMERS from comment #8)
> Note that using numeric search is only useful when using comparisons greater
> or lower than.

That's probably a valid point. We could probably add itemnumber to a non-numeric index for MARC21, although then we're indexing it twice when we could just index it once and change the CCL alias instead.

> Default search is phrase so indexing itemnumber subfield as phrase should be
> enough to allow searching : "itemnumber:9999"

I believe the default search is actually wordlist (:w), but that's true enough. In MARC21, the biblionumber is indexed like so: "Local-Number:n Local-Number:w Local-Number:s". So "local-number:9999" will get you the biblionumber stored in the local-number "w" index. The ":s" is probably unnecessary as that's just for sorting...
Comment 10 Jonathan Druart 2015-08-05 14:26:52 UTC
Created attachment 41382 [details] [review]
Bug 14031 - Itemnumber should be a numeric search in ccl.properties

This patch changes the "itemnumber" alias so that it acts like
"itemnumber,st-numeric". That is, it always does a numeric search.

_TEST PLAN_

The best way to test this patch is to apply the patch and then run
"make upgrade", I suspect. As this will refresh your "ccl.properties".

However, this patch is actually really small, so you can just apply
it manually to an existing "ccl.properties" if you rather save time.

Basically, you just need to do the following steps:

0) Do a search for "itemnumber:<insert real indexed itemnumber here>"
1) Note that you can't retrieve any results
2) Change your ccl.properties to say "itemnumber 1=8010 4=109"
3) Repeat the search for "itemnumber:<X>"
4) Note that you now retrieve your result

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Tested on a gitified package install. Made the change to
/etc/koha/zebradb/ccl.properties manually. After this change
I can successfully search for "itemnumber:1".

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 11 Tomás Cohen Arazi 2015-08-21 13:40:09 UTC
Patch pushed to master.

Thanks David!