简体   繁体   中英

Grails Searchable Plugin - Filtering Result Set

I am currently using Lucene. My requirement is like facebook search box. User search people and friends. But in my requirement user have privacy settings like name, location, email address are visible to everyone or only friends. He can show and hide these fields from friends and other members of the community.

I have implemented simple search on the basis of name, location and email address. But now i am modifying search on the basis of privacy settings.

Here is my scenario ..

User A has privacy settings:
Name is only shown to friends
Email is shown to every one
Location is not shown to any one.

If User X type location of the User A in the search box then it should not be in the results. But if User X type Name of User A in the search box then it should be shown because User A has not restricted name and it is visible to his friends in the privacy settings.

Can you please guide me to the approach.

Let me know if i have not clearly write my requirement.

I have analysed following approaches,
1- IndexSearcher's explain method (It will be hit overall performance)
2- Explored Filters But couldn't get much

My Approach:

Get the resultSet on the basis of name
Get the resultSet on the basis of location
Get the resultSet on the basisi of email address

Loop on each 3 result set and apply conditions related to privacy settings and exclude the items on the basis of privacy settings. And in the end merge all 3 results set.

If there is any other approach? Please share with me. Thanks.

may be you can use lucene query syntax in searchable plugin for creating lucene Query according to requirement.

you can find here or here

you can restrict seaching by overriding default property settings. You just need to apply like this....

class A {
      String x
      String y
      String z

    static searchable = [only: ['x', 'y']] 
    // …
}

Using this you can restrict searchable properties.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM