Not able to filter search result using searchable plugin

256 views Asked by At

I have been using Searchable to search contacts created by a user. So far, it is working fine. Now I want to implement filtration, like search those contacts which are "Buyer" type of contacts. For this, first the user has to select "Contact Type" from select box and search contacts by name.

My problem is it shows search results but they aren't filtered by Contact Type. Like when I select "Contact_Type" as "Buyer" and name as "vim", it shows search result with vim but without filtering on Contact_Type.

Search method in ContactController:

def search = {
    def query =  params.q
    def filterContact = params.filter

    if(query && filterContact){
        def srchResults = searchableService.search(query, filterContact)
        render(view: "list",
            model: [contactInstanceList: srchResults.results,
            contactInstanceTotal:srchResults.total])
    }
    else{
        render "not record found";
    }
}

Select box

<g:select style=" background:transparent;border:none;margin-bottom:10px;color:#787878;"  from="${com.vproc.enquiry.ContactType?.values()}"
            noSelection="['':'Search By']" value="${contactInstance?.contactType?.values()}" name="filter" />

JS method to redirect to search results:

<script type="text/javascript">
    function showContact(id){
        document.location.href ='/VProcureFinal/contact/search?q=' + $("#"+ id).val()
            + "&filter=" + $("#filter").val();
    }
</script>

Suppose I create a contact whose name is "Vim" and contact_type is "Buyer". When I search it with contact_type="Seller" and name="Vim', it still shows search result but it should not show this. Does anyone have any idea how to do this?

0

There are 0 answers