Skip to content
This repository has been archived by the owner on Mar 6, 2018. It is now read-only.

搜索条件的怪异问题 #10

Open
zhaoguobin opened this issue Dec 7, 2011 · 2 comments
Open

搜索条件的怪异问题 #10

zhaoguobin opened this issue Dec 7, 2011 · 2 comments

Comments

@zhaoguobin
Copy link

我使用Redis::Search.complete搜索,如果搜索ab,附带搜索条件与不附带搜索条件,返回结果都正确。
如果搜索a,不附带搜索条件,结果正确,附带搜索条件,无结果(数据库中有符合的记录)。

怪哉!

@huacnlee
Copy link
Owner

huacnlee commented Dec 7, 2011

实际的数据场景发出来看看

@zhaoguobin
Copy link
Author

Model: User

字段:id, username, deleted_at

username数据:a1, a2, a3, b1, b2, b3, b4,c1,c2,c3,c4,abc 。。。  大致这些
deleted_at: 全部为 nil

Model 索引:
redis_search_index(
    :title_field => :username, 
    :prefix_index_enable => true,
    :condition_fields => [:deleted_at]
  )

开了pinyin

Redis::Search.complete("User","a")
结果正常

Redis::Search.complete("User","a", :conditions => {:deleted_at => nil})
[ ]

Redis::Search.complete("User","a1")
[{"title"=>"a1", "id"=>29, "type"=>"User", "deleted_at"=>nil}]

Redis::Search.complete("User","a1", :conditions => {:deleted_at => nil})
[{"title"=>"a1", "id"=>29, "type"=>"User", "deleted_at"=>nil}]

“a1”的都正确!

新法现:

“ta"是随手输入的

Redis::Search.complete("User","ta")
[ ]

Redis::Search.complete("User","ta", :conditions => {:deleted_at => nil})
结果返回了非常多的无关结果


Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants