why is "!term f=" added to my search query?

29 views
Skip to first unread message

Alex Romanin

unread,
Apr 16, 2021, 10:11:29 AM4/16/21
to Blacklight Development
I can't find the answer to this anywhere! Is it legacy Solr?
I have facets configured as Strings (plural) multivalued string fields.
this works:
fq=fq=gpes_str%3ALondon
but in search_builder_spec.rb blacklight converts this to the following which does not return any results. I can override this following the instructions but why does it do this? I can't find any relevant documentation explaining what this syntax means...
fq={!term+f%3Dgpes_str}London

Benjamin Armintor

unread,
Apr 16, 2021, 10:59:01 AM4/16/21
to blacklight-...@googlegroups.com
The part of the query in curly brackets is identifying the query parser to be used for this filter (the 'term' parser) and the relevant term for the query ('gpes_str'). The part after the brackets is the value to use for the query ('London'). Using the term parser on a text field tells Solr not to apply further analysis to the value, which makes it useful for turning a facet into an exactly-matching refining query.

This is documented in the latest version of Solr here: https://solr.apache.org/guide/8_8/other-parsers.html#term-query-parser


Prior to this change Blacklight used the 'raw' parser for turning facets into filters (that parser is documented in the same page of Solr documentation linked above).

I am assuming there is a missing ampersand in your query string under "this works" above? The other value for fq there ('gpes_str:London') is going through the standard parser, I think.

- Ben

--
You received this message because you are subscribed to the Google Groups "Blacklight Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blacklight-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blacklight-development/e49ff98a-b6a4-4c2c-99cf-33bd598a1242n%40googlegroups.com.

Bill Dueber

unread,
Apr 16, 2021, 10:59:05 AM4/16/21
to blacklight-...@googlegroups.com

tl;dr — {!term f=gpes_str}London is exactly the same as gpes_str:"London" for this particular query. 

The {!query_parser_type f=field_name}query_words syntax is something you don’t see super often when people make queries by hand — they’re generally different/safer ways to specify parsing rules for a specific (part of) your query.

The term query parser doesn’t do any analysis (tokenizing, lowercasing, whatever), which is exactly what you want when doing a facet query — not a big change for this query, but you could do {!term f=gpes_str}Tower of London as well and no tokenization would happen. Other common ones are {!lucene and {!edismax (for those query parsers) and things like the field query parser, where {!field f=myfield}Hi there is equivalent to myfield:"Hi there" but you don’t have to worry about enclosing/escaping double quotes by yourself.

These can be especially useful when combining different query parsers using “localparams” syntax, so you can use the normal lucene AND/OR/NOT syntax, but have different clauses parsed/analyzed in different ways.

A list of the default available ones are at https://solr.apache.org/guide/8_8/other-parsers.html


On Fri, Apr 16, 2021 at 10:11 AM Alex Romanin <alexr...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "Blacklight Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blacklight-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blacklight-development/e49ff98a-b6a4-4c2c-99cf-33bd598a1242n%40googlegroups.com.


--
Bill Dueber
Library Systems Programmer
University of Michigan Library

Alex Romanin

unread,
Apr 16, 2021, 12:12:48 PM4/16/21
to Blacklight Development
aha! brilliant, thankyou so much for the speedy response!
Sorry for the typo, it should have been simply:
this works:
fq=gpes_str%3ALondon

So I understand that it would surely work perfectly if my facet field was a singular String field but I'm using a Strings (plural) multivalued string field which would work through the normal/raw parser and not the term one.

Thanks so much for the links and the help, it's really appreciated!


Alex Romanin

unread,
Apr 16, 2021, 12:14:24 PM4/16/21
to Blacklight Development
brilliant, thanks for the extra info - works perfectly on single string field but not multivalued facet that I'm using. Much appreciated!
Reply all
Reply to author
Forward
0 new messages