Solr Filter Query - String vs. Int

2019-04-29 07:24发布

问题:

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

回答1:

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.