问题
I am trying to use CRC32
to to randomize results in a Sphinx query which already has several nested orders e.g.
Select CRC32(Field) as Random from Index Order by Premium,Weight(),Random
However, the only unique field I have is a reference
. It is an integer so randomizes via CRC32 as 0
.
I selected it in my Sphinx Config Select...
referenceas Randomizer...
and then specified it as a string so I could use it in the select:
sql_field_string = Randomizer
So it would be 'converted' to text.
However when I run:
``Select CRC32(Randomizer) as Random from Index Order by Premium,Weight(),Random`
I get the alert in navicat as a pop-up "3997755376" is not a valid integer value. I'm not sure if this is a CRC32 limitation or Navicat.
回答1:
Does sound like a navicat issue. CRC32 in sphinx produces a unsigned 32bit interger.
Internally sphinx uses it as BIGINT
fixed #1643, CRC32() is now properly evaluated as unsigned in BIGINT context
from 2.2.10-release at least, which could be confusing navicat.
If you storing it in an attribute, anyway, could do it at indexing time (using mysql to process it!), rathr than doing it query time.
sql_query = Select id,CRC32(reference) as Randomizer...
sql_uint_string = Randomizer
来源:https://stackoverflow.com/questions/49179958/crc32-on-integer-in-sphinx