(思考)sphinx Extended2模式下如何进行属性匹配?

发布于 2024-09-19 16:59:53 字数 845 浏览 9 评论 0原文

我有这个表达式,它在 Thinking Sphinx 中按预期工作:

Customer.search :with => {:signer_id => 23}

但我需要编写一个带有某些属性的 OR 的表达式,例如 Signer_id 是 23 或 admin_level 是 42,所以我转到扩展匹配模式并写了这个

Customer.search "@signer_id 23", :match_mode => :extended2

:理解Sphinx相关文档,应该是等价的,但是它根本不匹配任何东西。有什么想法我做错了什么吗?如何编写扩展思维的狮身人面像表达式?

从控制台复制并粘贴:

ruby-1.8.7-p302 > Customer.search(:with => {:signer_id => 23}).count
 => 20 
ruby-1.8.7-p302 > Customer.search "@signer_id 23", :match_mode => :extended2
 => [] 
ruby-1.8.7-p302 > Customer.search("@signer_id 23", :match_mode => :extended2).count
 => 0

更新:修复了 ID (32 -> 23)。

I have this expression which is working as expected in Thinking Sphinx:

Customer.search :with => {:signer_id => 23}

but I need to write an expression with OR of some attributes, like signer_id is 23 or admin_level is 42, so I moved to extended match mode and wrote this:

Customer.search "@signer_id 23", :match_mode => :extended2

which according to my understanding of the Sphinx relevant documentation, it should be equivalent, but it doesn't match anything at all. Any ideas what am I doing wrong? How do I write an extended thinking sphinx expression?

Copied and pasted from the console:

ruby-1.8.7-p302 > Customer.search(:with => {:signer_id => 23}).count
 => 20 
ruby-1.8.7-p302 > Customer.search "@signer_id 23", :match_mode => :extended2
 => [] 
ruby-1.8.7-p302 > Customer.search("@signer_id 23", :match_mode => :extended2).count
 => 0

Update: fixed the id (32 -> 23).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

原来是傀儡 2024-09-26 16:59:53

我没有在文档中发现可以使用 @attribute value 语法的部分 - 它仅适用于字段,不适用于属性。至少,这是我的理解。如果我错了那就太好了:)

I'm not spotting the section in the docs that says you can use the @attribute value syntax - it's only for fields, not attributes. At least, that's my understanding. Would be fantastic if I'm wrong :)

等往事风中吹 2024-09-26 16:59:53

我这样做是为了对我已经标准化的字段进行匹配。通过在全文搜索中使用相同的文本,可以减少数据库中的流失量。

查询:'披萨| @产品代码(965|1636|1848|2939|4227|5067|5735)| @品牌代码 (1485) | @service_codes (2782)

请注意,正如其他答案指出的那样,您不能以这种方式处理属性,这些属性必须是索引字段。

我像这样暴力破解它们:

        indexes '(select group_concat(products.id) from business_products inner join products on (products.id = business_products.product_id) where business_id = `businesses`.`id` group by business_id)', :as => :product_codes, :type => :integer

另外,您需要通过设置此选项来减少单词中的字符数

  min_word_len: 1

,否则它将与您的 1 和 2 位数字代码不匹配。

I did this to do matching on fields that I have normalized out. This reduces the amount of churn in the db by having the same text in the full text search.

Querying: 'pizza | @product_codes (965|1636|1848|2939|4227|5067|5735) | @brand_codes (1485) | @service_codes (2782)

Note as the other answer points out you cannot do properties this way, these have to be indexed fields.

I brute force them out like this:

        indexes '(select group_concat(products.id) from business_products inner join products on (products.id = business_products.product_id) where business_id = `businesses`.`id` group by business_id)', :as => :product_codes, :type => :integer

Additionally you will need to reduce the number of characters in a word by setting this

  min_word_len: 1

Otherwise it won't match your 1 and 2 digit number codes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文