部分比赛不适用于使用searchkick的电话号码字段 [英] Partial match not working for phone number field using searchkick
问题描述
User.search( 9898989898,字段:[{first_name::word_start},
:middle_name,:last_name,:phone_number])
但是当提供部分查询时,即没有完全匹配,则不能获得搜索结果。
User.search(9898,fields:
注意:该查询可以是first_name,middle_name和last_name的字符串,而phone_number的数字
有没有人有这个想法?
如果您希望部分匹配电话号码字段以及first_name,则需要为这两个字段提供word_start。您可以尝试这样:
User.search(9898,fields:[{first_name::word_start},:middle_name, :last_name,{phone_number::word_start}])。
还有在用户模型中,请放两个字段
searchkick word_start:[:first_name ,:phone_number]
When the query is specified as given below i.e provided with the exact match then searchkick gives the result.
User.search("9898989898", fields: [{first_name: :word_start}, :middle_name, :last_name, :phone_number])
But when partial query is provided i.e without exact match then no search result is obtained.
User.search("9898", fields: [{first_name: :word_start}, :middle_name, :last_name, :phone_number]) This query does not give any result.
Note: The query can be string for first_name, middle_name and last_name whereas numeric for phone_number
Does anyone have idea on this?
If you want partial match for the phone number field as well as first_name you need to provide the word_start for both the fields. You may try this:
User.search("9898", fields: [{first_name: :word_start}, :middle_name, :last_name, {phone_number: :word_start}]).
And also in the User model please put both the fields searchkick word_start: [:first_name, :phone_number]
这篇关于部分比赛不适用于使用searchkick的电话号码字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!