CRC32 on integer in Sphinx

三世轮回 提交于 2019-12-13 03:48:17

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!