Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr Filter Query - String vs. Int

Say I'm trying to query a bunch of documents that have categories and I want to limit the queries to a specified category (as I understand it this would just be using the fq parameter (filter query).

I was wondering if there is a performance improvement for having the parameter be an integer instead of a string or something as is usually the case with data? I would just err on the right side but I thought I'd double check in case it didn't matter very much and Solr performed some sort of optimization under the hood?

It would be much more convenient if I could just filter on string matches but..

Thanks for any tips folks

like image 651
jstats Avatar asked Sep 19 '12 07:09

jstats


People also ask

What is filter query in SOLR?

Solr provides Query (q parameter) and Filter Query (fq parameter) for searching. The query (q parameter), as the name suggests, is the main query used for searching. Example. q = title:james. Filter queries are used alongside query (q parameter) to limit results of queries using additional filters.

What is the difference between Q and FQ in SOLR?

Standard solr queries use the "q" parameter in a request. Filter queries use the "fq" parameter. The primary difference is that filtered queries do not affect relevance scores; the query functions purely as a filter (docset intersection, essentially).

How to search in Solr query?

The main query for a solr search is specified via the q parameter. Standard Solr query syntax is the default (registered as the “lucene” query parser). If this is new to you, please check out the Solr Tutorial. Adding debug=query to your request will allow you to see how Solr is parsing your query.

How query all fields in Solr?

The correct way is the copyField you have and declaring the field all as the default search field. That's how the examples that ship with Solr out of the box do it. Excellent, adding <str name="df">all</str> to defaults in solrconfig. xml indeed solved this.


1 Answers

Unless you need to perform range queries (numeric fields have special support for this) or sorting (the int field cache is more memory-efficient than the String field cache), they should be roughly equivalent.

like image 84
jpountz Avatar answered Sep 22 '22 13:09

jpountz