# "Playing" with ElasticSearch Grails plugin

**URL:** <https://discuss.elastic.co/t/playing-with-elasticsearch-grails-plugin/9108>\
**Category:** Elasticsearch\
**Created:** [September 23, 2012, 12:20am UTC](https://discuss.elastic.co/t/playing-with-elasticsearch-grails-plugin/9108 "2012-09-23T00:20:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_Asensio](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@Alejandro\_Asensio](https://discuss.elastic.co/u/Alejandro_Asensio)\
**Post date:** [September 23, 2012, 12:20am UTC](https://discuss.elastic.co/t/playing-with-elasticsearch-grails-plugin/9108/1 "2012-09-23T00:20:20Z")

</div>

First of all i must say that ES looks pretty good.

After that, i should say that I'm new in search engines so do blame my due  
to my silly questions.

I have configured my Domain Class called (News) using searchable = true.  
Data seems to be indexed and when I do a search it retreives 50 results,  
but the 'searchResults' variable is totally empty. How can this be  
possible, maybe because of the low score of the search?If that is the case,  
how can I improve the score and the search.

I have tried to find the solution to this "issue" but I had no luck.

Thanks in advance!

--

---

<div class="post-metadata">

**Author:** ![Alejandro\_Asensio](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@Alejandro\_Asensio](https://discuss.elastic.co/u/Alejandro_Asensio)\
**Post date:** [September 23, 2012, 12:25am UTC](https://discuss.elastic.co/t/playing-with-elasticsearch-grails-plugin/9108/2 "2012-09-23T00:25:51Z")

</div>

Just in order to complete my question....

The code inside the Search Controller

def elasticSearchService

```
def search(){
    def res = elasticSearchService.search("${params.query}")

    println res.searchResults

    println "Found ${res.total} result(s)"
    res.searchResults.each {
        if(it instanceof News) {
            println "------------"
            println "Title:"+it.title
            println "Body"+it.body
            println "------------"
        } else {
            println it.toString()
        }
    }
}

```

The code for indexing News

static searchable = {  
only = ['title','body']  
}

And the output given by the controller is:

Found 50 result(s)

Thanks!

On Sunday, September 23, 2012 2:20:20 AM UTC+2, Alejandro Asensio wrote:

> First of all i must say that ES looks pretty good.
> 
> After that, i should say that I'm new in search engines so do blame my due  
> to my silly questions.
> 
> I have configured my Domain Class called (News) using searchable = true.  
> Data seems to be indexed and when I do a search it retreives 50 results,  
> but the 'searchResults' variable is totally empty. How can this be  
> possible, maybe because of the low score of the search?If that is the case,  
> how can I improve the score and the search.
> 
> I have tried to find the solution to this "issue" but I had no luck.
> 
> Thanks in advance!

--

---

<div class="post-metadata">

**Author:** ![thch](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@thch](https://discuss.elastic.co/u/thch)\
**Post date:** [September 25, 2012, 9:52am UTC](https://discuss.elastic.co/t/playing-with-elasticsearch-grails-plugin/9108/3 "2012-09-25T09:52:35Z")

</div>

Hi,

could you please try to set the params.indices and params.types for the  
search method?

```
    def params =[:]
    String indices = "newsxpath" //your package name to the class to 

```

search.  
params.indices = indices

```
    String types = "newsxpath.News" // your class name
    params.types = types

   def res = elasticSearchService.search("${params.query}",params) 

```

This works for me.

Am Sonntag, 23. September 2012 02:25:51 UTC+2 schrieb Alejandro Asensio:

> Just in order to complete my question....
> 
> The code inside the Search Controller
> 
> def elasticSearchService
> 
> ```
> def search(){
> def res = elasticSearchService.search("${params.query}")
> 
> println res.searchResults
> 
> println "Found ${res.total} result(s)"
> res.searchResults.each {
> if(it instanceof News) {
> println "------------"
> println "Title:"+it.title
> println "Body"+it.body
> println "------------"
> } else {
> println it.toString()
> }
> }
> }
> 
> ```
> 
> The code for indexing News
> 
> static searchable = {  
> only = ['title','body']  
> }
> 
> And the output given by the controller is:
> 
> Found 50 result(s)
> 
> Thanks!
> 
> On Sunday, September 23, 2012 2:20:20 AM UTC+2, Alejandro Asensio wrote:
> 
> > First of all i must say that ES looks pretty good.
> > 
> > After that, i should say that I'm new in search engines so do blame my  
> > due to my silly questions.
> > 
> > I have configured my Domain Class called (News) using searchable = true.  
> > Data seems to be indexed and when I do a search it retreives 50 results,  
> > but the 'searchResults' variable is totally empty. How can this be  
> > possible, maybe because of the low score of the search?If that is the case,  
> > how can I improve the score and the search.
> > 
> > I have tried to find the solution to this "issue" but I had no luck.
> > 
> > Thanks in advance!

--

---

<div class="post-metadata">

**Author:** ![thch](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@thch](https://discuss.elastic.co/u/thch)\
**Post date:** [September 25, 2012, 10:10am UTC](https://discuss.elastic.co/t/playing-with-elasticsearch-grails-plugin/9108/4 "2012-09-25T10:10:46Z")

</div>

I don't know why my answer was deleted,  
but the following worked for me. I had the same problem.

```
     def params =[:]
    String indices = "newsindex" // path to your package 
    params.indices = indices

    String types = "addresses.News" // full class name 
    params.types = types

    def res = elasticSearchService.search("*",params)

```

Greetings

Am Sonntag, 23. September 2012 02:25:51 UTC+2 schrieb Alejandro Asensio:

> Just in order to complete my question....
> 
> The code inside the Search Controller
> 
> def elasticSearchService
> 
> ```
> def search(){
> def res = elasticSearchService.search("${params.query}")
> 
> println res.searchResults
> 
> println "Found ${res.total} result(s)"
> res.searchResults.each {
> if(it instanceof News) {
> println "------------"
> println "Title:"+it.title
> println "Body"+it.body
> println "------------"
> } else {
> println it.toString()
> }
> }
> }
> 
> ```
> 
> The code for indexing News
> 
> static searchable = {  
> only = ['title','body']  
> }
> 
> And the output given by the controller is:
> 
> Found 50 result(s)
> 
> Thanks!
> 
> On Sunday, September 23, 2012 2:20:20 AM UTC+2, Alejandro Asensio wrote:
> 
> > First of all i must say that ES looks pretty good.
> > 
> > After that, i should say that I'm new in search engines so do blame my  
> > due to my silly questions.
> > 
> > I have configured my Domain Class called (News) using searchable = true.  
> > Data seems to be indexed and when I do a search it retreives 50 results,  
> > but the 'searchResults' variable is totally empty. How can this be  
> > possible, maybe because of the low score of the search?If that is the case,  
> > how can I improve the score and the search.
> > 
> > I have tried to find the solution to this "issue" but I had no luck.
> > 
> > Thanks in advance!

--

---

<div class="post-metadata">

**Author:** ![thch](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@thch](https://discuss.elastic.co/u/thch)\
**Post date:** [September 25, 2012, 10:31am UTC](https://discuss.elastic.co/t/playing-with-elasticsearch-grails-plugin/9108/5 "2012-09-25T10:31:38Z")

</div>

Ok, this is my third try to post. The other posts were deleted. Don't know  
why.

I had the same problem while using the grails-elasticsearch-plugin.

Try adding indices and types. This worked for me. So searchResults weren't  
empty anymore.

```
    def params =[:]
    String indices = "newsindex"
    params.indices = indices

    String types = "newsindex.News"
    params.types = types

    def res = elasticSearchService.search("*",params)

```

--

---

<div class="post-metadata">

**Author:** ![Chittibabu\_Nanjan](https://avatars.discourse-cdn.com/v4/letter/c/c37758/32.png) [@Chittibabu\_Nanjan](https://discuss.elastic.co/u/Chittibabu_Nanjan)\
**Post date:** [May 28, 2014, 11:46am UTC](https://discuss.elastic.co/t/playing-with-elasticsearch-grails-plugin/9108/6 "2014-05-28T11:46:00Z")

</div>

Hi ,

I am using ES in grails. I have implemented ES plugin in grails PlugIn with  
out fail. I was wright some statement in controller like  
Code :

* * *

params.query="i like to add messages"  
def resultsTweets = Tweet.search("message:${params.query}")  
println"resultsTweets##### "+resultsTweets

* * *

This Statement is giving some result. but i unable to use more parameter in  
this search. How I use more search criteria for get the result from ES.  
please help me

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2bbeadb6-7647-4ea5-8915-69a887a04786%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2bbeadb6-7647-4ea5-8915-69a887a04786%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:26am UTC](https://discuss.elastic.co/t/playing-with-elasticsearch-grails-plugin/9108/7 "2017-07-06T01:26:21Z")

</div>


