【问题标题】:How to create text index in mongoid 5?如何在 mongoid 5 中创建文本索引?
【发布时间】:2016-06-20 11:11:04
【问题描述】:

我的模型中有这个

index({company_name: 1, first_name: 1, last_name: 1 })

Model.text_search 'something'

给出这个错误

Mongo::Error::OperationFailure: text index required for $text query

【问题讨论】:

    标签: mongodb mongoid mongoid5


    【解决方案1】:

    我找到了解决办法

    index({company_name: 'text', first_name: 'text', last_name: 'text' })

    您只需传递“文本”而不​​是 1。

    【讨论】:

      猜你喜欢
      • 2017-06-14
      • 1970-01-01
      • 2014-10-21
      • 2018-04-25
      • 2011-12-06
      • 2021-01-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多