Sphinx 2.0.2 Filtering sql_attr_string Attributes

陌路散爱 提交于 2019-12-20 06:29:57

问题


Firstly, let me say that I know that http://sphinxsearch.com/docs/current.html#conf-sql-attr-string says "strings can only be used for storage and retrieval" and that "They can not participate in expressions, be used for filtering, sorting, or grouping"...

Having said that, using Sphinx 2.0.2, accessing the index via both the SQL interface (on port 9306) as well as via SphinxSE I am able to sort, at least, on a string attribute I have.

So although that doesn't necessarily mean that the documentation is completely wrong, it does leave me with a small amount of hope that I can filter by that string attribute, too.

Unfortunately I don't know if I can, and if I can, I don't know how.

Can someone here please put me out of my misery?

[EDIT]

The attribute is 'mail_street_name' and I've tried filtering it a number of ways. Trying to filter on 'box', for example, in the SphinxSE query string I've tried filter=mail_street_name,box, filter=mail_street_name,"box" and filter=mail_street_name,\'box\' (escaped because it sits inside a string). These queries result in no change to the result set (as if I didn't try and filter on that attribute at all).

With the MySQL connection on port 9306 I've tried WHERE mail_street_name='box', WHERE mail_street_name="box", WHERE mail_street_name=box and using LIKE instead of =, all to be given a syntax error (Error 1064 (42000)) from SphinxQL.

Many thanks.


回答1:


As I stated in my last comment, you could try defining a field (http://sphinxsearch.com/docs/current.html#conf-sql-field-string).

You could do a WHERE MATCH((@mail_street_name '*box*'))

And according to the documentation, you are still able to sort on it also



来源:https://stackoverflow.com/questions/8718014/sphinx-2-0-2-filtering-sql-attr-string-attributes

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