"Playing" with ElasticSearch Grails plugin


(Alejandro Asensio) #1

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!

--


(Alejandro Asensio) #2

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!

--


(thch) #3

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!

--


(thch) #4

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!

--


(thch) #5

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)

--


(Chittibabu Nanjan) #6

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/2bbeadb6-7647-4ea5-8915-69a887a04786%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #7