I have one field that is indexed as string in Solr’s schema.xml, which is from a boolean(tinyint) column in mysql database.
In query, I search against this field using 1. But without any change, this query cannot return correct results as it did. After I used true instead of 1, it worked again. Now it goes wrong again but with true, no problem with 1.
What’s the exact problem here? Do I need change the field type in schema.yml to integer?
Thank you in advance.
Since it’s a string field, we can’t possibly know how you indexed it. It could be “true” / “false” or “1” / “0” or “on” / “off”, etc. Or even a mix of these, maybe you have some documents with “true” and some with “1”.
If it’s semantically a boolean field I recommend using the boolean fieldType, e.g.:
for this to work you need the boolean fieldType declared (it comes declared in the default schema):
Remember to rebuild the index after this change.