RE: SolrMARC - dynamic fields booleans and conditionals

7 views
Skip to first unread message

Demian Katz

unread,
Feb 22, 2019, 11:02:28 AM2/22/19
to Katzmann, Michael, vufind-...@lists.sourceforge.net, solrma...@googlegroups.com

Does putting the 1 in double quotes make a difference?

 

I’m copying the solrmarc-tech list into this thread so people there can weigh in as well if my suggestion proves unhelpful.

 

- Demian

 

From: Katzmann, Michael <mk...@loc.gov>
Sent: Friday, February 22, 2019 10:10 AM
To: vufind-...@lists.sourceforge.net
Subject: [VuFind-General] SolrMARC - dynamic fields booleans and conditionals

 

I am trying to get a dynamic Boolean to work with a conditional in solrmarc.

No matter what I try, I get an error. Is it even possible to assign an Boolean with a conditional or does a conditional have to use the MARC field as is ?

 

 

LoC_reissue_bool = 1 ? (534c contains “reissue”)

 

I guess it’s treating ‘1’ as a marc field rather than a 1/0/t/f.

 

 

 

Michael Katzmann,
Chief, Materials Development Division
NLS/BPH Library of Congress

1291 Taylor Street NW
Washington DC 20542
📞+1 202.707.0701     📧    MK...@LoC.Gov

For secure email encrypt with my GPG/PGP Public Key
Import NLS/BPH authority certificate to verify electronic signatures

 

 

Demian Katz

unread,
Feb 22, 2019, 11:35:06 AM2/22/19
to Katzmann, Michael, solrma...@googlegroups.com

I suspected you probably had, but it never hurts to be sure. 😊

 

I imagine you’ve also tried literal “t” and “T” as alternatives to “1” but again I’ll mention them for the sake of comprehensiveness. 😊

 

Looking at the examples in the wiki, I don’t see any with string literals, which makes me wonder if perhaps that case is not supported (though I think it probably should be!). Perhaps Bob can weigh in on this situation; he’s much more familiar with these capabilities than I am.

 

In the meantime, if you’re really desperate, is there a way to cheat and specify a MARC field that’s always set to 1? For example, is there some position of the leader that can be relied on? I realize that’s a completely stupid hack and the mere suggestion may be harmful to my reputation, but for the purposes of testing the remainder of the expression, it might be interesting to try while waiting for a better (sane) answer. 😉

 

- Demian

 

From: Katzmann, Michael <mk...@loc.gov>
Sent: Friday, February 22, 2019 11:11 AM
To: Demian Katz <demia...@villanova.edu>
Subject: RE: SolrMARC - dynamic fields booleans and conditionals

 

No .. I thought of that 8-)

 

---

Michael Katzmann,
Chief, Materials Development Division
NLS/BPH Library of Congress

📞+1 202.707.0701     📧    MK...@LoC.Gov

Demian Katz

unread,
Feb 22, 2019, 11:58:17 AM2/22/19
to Katzmann, Michael, solrma...@googlegroups.com

Yes, the pattern map solution is far less ridiculous than my proposed idea!

 

I would think that returning an appropriate string from SolrMarc should map appropriately to the Boolean value in Solr, but I’ve never tried it, so that may be blind optimism. I’ll be interested to hear your findings!

 

- Demian

 

From: Katzmann, Michael <mk...@loc.gov>
Sent: Friday, February 22, 2019 11:56 AM
To: Demian Katz <demia...@villanova.edu>
Cc: solrma...@googlegroups.com
Subject: RE: SolrMARC - dynamic fields booleans and conditionals

 

OK, yes I did try t and ‘t’. I also looked at the SolrMARC page and only saw direct assignment of a MARC field for a conditional.

I tried using a pattern match transformation =>1 (this didn’t seem to work yesterday but when I just tried it again it didn’t complain. I’ll check to see if it actually added the Boolean.)

I’m OK in adding a Java class but I’m not sure if I still return a string with “1” or some other type if it’s being assigned to a boolean. (I resume a string)

 

Michael

Haschart, Robert J (rh9ec)

unread,
Feb 22, 2019, 2:16:24 PM2/22/19
to Katzmann, Michael, solrma...@googlegroups.com

The pattern map solution Demian mentions should work, mostly.  It is relatively easy to have a LOC_reissue filed with a given value if field 534c exists and contains the text "reissue", and to NOT have that Solr field if the field 534c doesn't exist and/or doesn't contain the text "reissue"


LoC_reissue_bool = 534c, map("reissue=>true")

If you want a true/false value stored depending on whether that field exists and contains the desired value its a little harder, since since you'd have to write a Regex that matches all strings that do not contain a given string.  And since if that field doesn't exist, the rule wouldn't be evaluated.


About the best I've been able to come up with, (which only works with the latest SolrMarc version (3.2) ) is to use the above line, followed by a rule that uses the new  ?=  operator (which adds a index value IFF there is no current value defined for that index field)


LoC_reissue_bool = 534c, map("reissue=>true")

LoC_reissue_bool ?= "false"


-Bob


From: solrma...@googlegroups.com <solrma...@googlegroups.com> on behalf of Demian Katz <demia...@villanova.edu>
Sent: Friday, February 22, 2019 11:58:10 AM
To: Katzmann, Michael
Cc: solrma...@googlegroups.com
Subject: [solrmarc-tech] RE: SolrMARC - dynamic fields booleans and conditionals
 
--
You received this message because you are subscribed to the Google Groups "solrmarc-tech" group.
To unsubscribe from this group and stop receiving emails from it, send an email to solrmarc-tec...@googlegroups.com.
To post to this group, send email to solrma...@googlegroups.com.
Visit this group at https://groups.google.com/group/solrmarc-tech.
For more options, visit https://groups.google.com/d/optout.

Katzmann, Michael

unread,
Feb 25, 2019, 9:15:20 AM2/25/19
to Demian Katz, solrma...@googlegroups.com

OK, yes I did try t and ‘t’. I also looked at the SolrMARC page and only saw direct assignment of a MARC field for a conditional.

I tried using a pattern match transformation =>1 (this didn’t seem to work yesterday but when I just tried it again it didn’t complain. I’ll check to see if it actually added the Boolean.)

I’m OK in adding a Java class but I’m not sure if I still return a string with “1” or some other type if it’s being assigned to a boolean. (I resume a string)

 

Michael

 

---

Katzmann, Michael

unread,
Feb 25, 2019, 4:39:03 PM2/25/19
to Haschart, Robert J (rh9ec), solrma...@googlegroups.com

Thanks Bob, I tried your suggestion and it failed (at first) …

I looked at solr/vufind/biblio/conf/schema.xml and I think it needs to be _boolean  (not _bool)

 

LoC_reissue_boolean = 534p, map("Reissue=>true")

 

Works… 

 

I think the documentation page is incorrect

https://vufind.org/wiki/development:architecture:solr_index_schema

 

I’ll see if I can splice in the 3.2 jars to try your second suggestion.

 

Michael

---

Michael Katzmann,
Chief, Materials Development Division
NLS/BPH Library of Congress
📞+1 202.707.0701     📧    MK...@LoC.Gov

 

Demian Katz

unread,
Feb 25, 2019, 5:00:26 PM2/25/19
to solrma...@googlegroups.com, Haschart, Robert J (rh9ec)

Michael,

 

You are correct, there is a typo in the documentation – that’s gone a very long time without being caught. Sorry about that; it’s fixed now!

 

- Demian

Reply all
Reply to author
Forward
0 new messages