0

I have a complex searchable configuration for a domain class and its associated domain classes. when I search for about 200 results (max:200) it takes too long to respond.

in the result set I have all fields (simple or association) specified for search in my domain class. I need to return only an id list and ignore other fields of domain class. is it possible? I want to do this for speeding up my search. this id list will be used for querying another no-sql db. it seems that fetching all of the fields is slowing down my search.

Farzin Zaker
  • 3,578
  • 3
  • 25
  • 35
  • If I remember right, the results that searchable return are proxies, what means that if you don't try to access another properties apart from the id, it shouldn't load them from the database. Have you tried to activate sql logging to see the queries sent to the DB to see if it's querying too much? – Eylen May 22 '13 at 13:58
  • No, it's not querying DB along retrieving search results. when I set max:10 it finds results count and returns 10 items and when I set max:1000 it takes 100 times more time to respond. – Farzin Zaker May 22 '13 at 14:13
  • 1
    Sorry, I misunderstood the question. Without knowing your domain classes it's difficult to give a clear solution, but if you're not interested in some fields and don't want to index them, you could just exclude them from the index, or if you want to retrieve them but not search by them, you could index but not analyze them. – Eylen May 22 '13 at 14:24
  • the question is exactly reverse of your solution. I need to search by some fields and not retrieve them. is this possible? – Farzin Zaker May 22 '13 at 17:45

1 Answers1

1

I think you can achieve what you want (let the property be searchable but not return it) by setting the property store to no.

For example:

class MyDomain {
    String name
    String email

    static searchable = {
        email index:'analyzed', store:'no'
        name index:'analyzed'
    }
}

In this domain I say that name and email are indexed and analyzed (so they can be searched) but the email property is not being stored, so it will be null when the object is returned. For other properties check: http://grails.org/Searchable+Plugin+-+Mapping+-+Searchable+Property

Eylen
  • 2,617
  • 4
  • 27
  • 42